Hi All,
Here is my scenario, The user transitions from one image view to the
other. After performing some actions on the second image view, he may
want to go back to the first one. He presses the back button
(LeftBarButtonItem) and then when he returns to the second view, I
want him to have the same state at which he left off. my second view is an array of imageViews.
This is how I am trying to implement this
-(void) retrieveFromUserDefaults
{
NSUserDefaults * standardDefaults = [NSUserDefaults standardUserDefaults];
NSData * tempObject = [ standardDefaults objectForKey:@"myKeyToSave" ];
NSArray *arr = [NSKeyedUnarchiver unarchiveObjectWithData:tempObject];
myImageViewArr = [NSMutableArray arrayWithArray:arr];
}
-(void)saveToUserDefaults
{
NSUserDefaults * standardDefaults = [NSUserDefaults standardUserDefaults];
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:myImageViewArr];
[standardDefaults setObject:data forKey:@"myKeyToSave"];
}
- (id) initWithCoder: (NSCoder *)decoder
{
myImageViewArr = [decoder decodeObjectForKey:keyToSave];
return myImageViewArr;
}
- (void) encodeWithCoder: (NSCoder *)encoder
{
[encoder encodeObject:myImageViewArr forKey:keyToSave];
}
- (void)viewWillDisappear

BOOL)animated {
[self saveToUserDefaults];
}
My App just seems to crash. Can anyone point me in the right direction as what I am doing wrong?
Thanks
Ajit