You need to declare your function in the header file.
You should add a line like this :
-(returnType)base64Encoding;
Where returnType
is the type returned by your method, like NSString*
, NSInteger
, void
or whatever your method returns.
Question
In my application when i try with following coding i get the warning as
Code
[UIImageJPEGRepresentation(petAvadar.image, 1.0)base64Encoding]
WARNING
Instance method '-base64Encoding' not found (return type defaults to 'id')
How to remove this warning,Please help me to solve.
Solution 2
You need to declare your function in the header file.
You should add a line like this :
-(returnType)base64Encoding;
Where returnType
is the type returned by your method, like NSString*
, NSInteger
, void
or whatever your method returns.
OTHER TIPS
Then convert your UIImage object into NSData the following way:
NSData *imageData = UIImageJPEGRepresentation(image, 1.0);
And then apply Base64 encoding to convert it into a base64 encoded string:
NSString *encodedString = [imageData base64Encoding];
Make sure that you have donlaoded Base64 lib classes from here
then import Base64.h use below code snip
For Encoding Image to Base64
NSData* data = UIImageJPEGRepresentation(yourImage, 1.0f);
[Base64 initialize];
NSString *strEncoded = [Base64 encode:data];
and Decode Base64 as image:
[Base64 initialize];
NSData* data = [Base64 decode:strEncoded ];;
image.image = [UIImage imageWithData:data];