我的应用程序中有一个方法,我想将十六进制值写入文件(本质上是从写入的字节创建图像)。我似乎无法弄清楚如何正确编码这些值以生成图像。任何建议将不胜感激 - 谢谢。
- (void)makeImage {
@autoreleasepool {
NSString* hexValues = @"8950..." // these are the hex bytes that make up the image file
NSString* fileName = @"image.png";
NSString* homeDir = [NSHomeDirectory() stringByAppendingPathComponent:@"Desktop/"];
NSString* fullPath = [homeDir stringByAppendingPathComponent:fileName];
NSError* error = nil;
[lastLine writeToFile:fullPath atomically:NO encoding:NSASCIIStringEncoding error:&error];
}