[英]get a string from UIImage in swift
I have image loaded from UIImagePickerController into UIImageView 我已将图像从UIImagePickerController加载到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 有人可以帮忙吗
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.