title: iPhone:How can I store UIImage using NSUserDefaults?
body: <p>I cannot save image using nsuserdefaults and crash my app and I also used custom class UserInfo which used </p>
  
  <pre><code>-(void)encodeWithCoder:(NSCoder *)encoder
  {
     NSData *imageData = UIImagePNGRepresentation(categoryImage);
     [encoder encodeObject:categoryName forKey:@"name"];
     [encoder encodeObject:imageData forKey:@"image"];
  }
  </code></pre>
  
  <p>-(id)initWithCoder:(NSCoder *)decoder and <strong>userInfo.categoryImage is UIImage variable.</strong></p>
  
  <p><strong>reason: '-[UIImage encodeWithCoder:]: unrecognized selector sent to instance 0x7676a70'</strong></p>
  
  <pre><code>userInfo = [[UserInfo alloc] init];
  
  userInfo.categoryName = categoryName.text;
  NSLog(@"Category Name:---&gt;%@",userInfo.categoryName);
  
  userInfo.categoryImage = image;
  
  appDelegate.categoryData = [[NSMutableDictionary dictionaryWithObjectsAndKeys:
                                   userInfo.categoryName, @"name",userInfo.categoryImage,@"image", nil] mutableCopy];
  
  
  [appDelegate.categories addObject:appDelegate.categoryData];
  NSLog(@"Category Data:---&gt;%@",appDelegate.categories);
  
  [appDelegate.categories addObject:userInfo.categoryName];
  [appDelegate.categories addObject:userInfo.categoryImage];
  
  [self saveCustomObject:userInfo.categoryName];
  
  [self saveCustomObject:userInfo.categoryImage];
  
  
  -(void)saveCustomObject:(UserInfo *)obj
  {
      appDelegate.userDefaults = [NSUserDefaults standardUserDefaults];
      NSData *myEncodedObject = [NSKeyedArchiver archivedDataWithRootObject:obj];
  
  
      [appDelegate.userDefaults setObject:myEncodedObject forKey:@"myEncodedObjectKey"];
  }
  </code></pre>
  
  <p>So Please help me how can i store and retrieve uiimage using nsusedefaults???</p>