将十六进制字符串转换为 NSData
如何转换十六进制格式的字符串以从中检索 NSData,然后在我的 iPhone 应用程序中检索 UIImage?
我有一个字符串 (str),其中包含类似 X'FFD8FFE000104A46....01010000010001000' 的值。
该字符串是通过以下方法从 xml 文件创建的:
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
str = [str stringByAppendingString:string];
}
How can I get the image back from that string?
预先感谢,
安德里亚
How can I convert a string in hex format to retrieve from it an NSData and after that an UIImage inside of my iPhone app?
I've got a string (str) that contains a value like X'FFD8FFE000104A46....01010000010001000'.
That string is created from a xml file by the method:
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
str = [str stringByAppendingString:string];
}
How can I get the image back from that string?
Thanks in advance,
Andrea
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
要将 NSData 转换为 NSString,请尝试“initWithData:encoding:”
将 NSData 转换为 UIImage,请尝试“imageWithData:”
For converting NSData to a NSString, try "initWithData:encoding:"
For converting NSData to an UIImage, try "imageWithData:"
您可能会找到 GTMStringEncoding 有帮助,来自 Google Toolbox For Mac。
You may find GTMStringEncoding helpful, from Google Toolbox For Mac.
我的示例代码,已更新!
my sample code , updated!