Convert nsdictionary to nsdata

后端 未结 5 2103
伪装坚强ぢ
伪装坚强ぢ 2021-02-05 19:38

have an app that can take a picture and then upload to a server. encoding it to base 64 and pass it thru a XMLRPC to my php server.

i want to take the NSDictionary info

5条回答
  •  春和景丽
    2021-02-05 20:09

    I know a bit too late, but just in case someone bumps into this same issue. UIImage is not serializable, but you can serialize it using the code:

    if your image is JPG:

    NSData *imagenBinaria = [NSData dataWithData:UIImageJPEGRepresentation(imagen, 0.0)]; 
    
    // imagen is a UIImage object
    

    if your image is PNG:

    NSData *imagenBinaria = [NSData dataWithData:UIImagePNGRepresentation(imagen)]; 
    
    // imagen is a  UIImage object
    

提交回复
热议问题