Advertisement
Guest User

Untitled

a guest
Jul 7th, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   UIImage* image;
  2.    
  3.     NSData* imageData = [[NSUserDefaults standardUserDefaults] objectForKey:@"image"];
  4.    
  5.    
  6.     if (imageData == (id)[NSNull null] || imageData.length == 0) {
  7.         NSLog(@"image data is %@",imageData);
  8.         image = [UIImage imageNamed:@"defaultIcon.png"];
  9.     }
  10.     else {
  11.         image = [UIImage imageWithData:imageData];
  12.        
  13.     }
  14.  
  15. This is how I am retrieving
  16.  
  17. This is how I am saving.
  18.  [[NSNotificationCenter defaultCenter] postNotificationName:@"SwitchToHome" object:nil];
  19.    
  20.     [[NSUserDefaults standardUserDefaults] setObject:UIImagePNGRepresentation(self.imgView.image) forKey:@"image"];
  21.    
  22.     [[NSUserDefaults standardUserDefaults] setInteger:self.imgView.image.imageOrientation forKey:@"imageOrientation"];
  23.  
  24.     [[NSUserDefaults standardUserDefaults] synchronize];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement