I have image loaded from UIImagePickerController into UIImageView
I need to convert the image into string to send it to the server
This is my code but it gives an error
var imageData:String = "";
if let unwrappedImage = profileImage.image {
let imageNSData : NSData = UIImageJPEGRepresentation(unwrappedImage, 1.0)!;
imageData = (NSString(data:imageNSData, encoding:NSUTF8StringEncoding) as String?)!
}
I am getting the following exception
fatal error: unexpectedly found nil while unwrapping an Optional value
can any one help please
Convert the data information of a image to a string , you will get a very very very long string, why not loaded the data to the server. Alamofire can do it easily, just see the uploading file part.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.