iOS 开发中实用小知识点

1.图片上传base64转码 转义特殊字符

- (NSString*)sealImage:(UIImage*)_sealImage {

    NSData *data = UIImageJPEGRepresentation(_sealImage, 0.2f);

    NSString *encodedImageStr = [data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];

    NSString * lrImage = [encodedImageStr stringByReplacingOccurrencesOfString:@"\r" withString:@""];

    NSString *baseString = (__bridge NSString *) CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,(CFStringRef)lrImage, NULL,CFSTR(":/?#[]@!$&’()*+,;="), kCFStringEncodingUTF8);

    return baseString ;

}






你可能感兴趣的:(iOS源码,iOS问题合集)