Running under iOS8 seems to have broken some code that I use to maintain the user's preference for the background image. I start with the default image (FACE1.png) and save this as my default preference. However, when unarchiving the image, if the default is still set, the dearchived image was bad.
Here is a snippet of code to show what is going wrong
UIImage *segment1Image = [UIImage imageNamed:@"FACE1.png"];
if (!segment1Image) {
NSLog(@"segment1Image nil pointer");
} else {
NSLog(@"The segment1Image image size is %f, %f", segment1Image.size.width, segment1Image.size.height);
NSData *segment1ArchiveData = [NSKeyedArchiver archivedDataWithRootObject:segment1Image];
if (!segment1ArchiveData) {
NSLog(@"segment1ArchiveData nil pointer, NSKeyedArchiver couldn't create archive");
} else {
NSLog(@"The archive is %d bytes", [segment1ArchiveData length]);
UIImage *unarchivedSegment1Image = [NSKeyedUnarchiver unarchiveObjectWithData:segment1ArchiveData];
if (!unarchivedSegment1Image) {
NSLog(@"unarchivedSegment1Image nil pointer, NSKeyedUnarchiver couldn't restore from archive");
} else {
NSLog(@"The unarchivedSegment1Image image size is %f, %f", unarchivedSegment1Image.size.width, unarchivedSegment1Image.size.height);
}
}
}
In iOS 7, the image is loaded, the archive is created and the archive is restored. The following output is generated on the console.
1Image 508.000000, 642.000000
- 408
unarchivedSegment1Image 508.000000, 642.000000
iOS8 , ( ), , UIImage 0
1Image 508.000000, 642.000000
- 653
unarchivedSegment1Image 0,000000, 0,000000
I
NSData *fullImageData = UIImagePNGRepresentation(segment1Image);
PNG , , , UIImage, imageNamed