When I look at the console while my iphone app is shutting down, it appears as though my encodewithcoder is being called twice. Even though I only encode an array of 'NewsItems' once.
Is this normal?
(void)encodeWithCoder:(NSCoder *)encoder {
NSLog(@"News encode called %@", self.title);
[encoder encodeObject:self.newsItemId forKey:KNewsItemNewsIdKey];
[encoder encodeObject:self.title forKey:KNewsItemTitleKey];
[encoder encodeObject:self.author forKey:KNewsItemAuthorKey];
[encoder encodeObject:self.description forKey:KNewsItemDescriptionKey];
[encoder encodeObject:self.imageUrl forKey:KNewsItemImageUrlKey];
[encoder encodeObject:self.thumbnailUrl forKey:KNewsItemThumbnailUrlKey];
[encoder encodeObject:self.createdAt forKey:KNewsItemCreatedAtKey];
//Images
//convert from PNG to NSData, other method available for JPG
NSData *savedImageData = UIImagePNGRepresentation(self.savedImage);
[encoder encodeObject:savedImageData forKey:KNewsItemSavedImageKey];
NSData *thumbnailImageData = UIImagePNGRepresentation(self.savedThumbnail);
[encoder encodeObject:thumbnailImageData forKey:KNewsItemSavedThumbnailKey];
}
//code to encode
[archiver encodeObject:self.newsArray forKey:KNewsArrayDataKey];