title: How to save custom objects in array and store it in NSUserDefaults - iPhone
body: <p>I am getting my custom class object after button action method. Now I need to store multiple custom objects in <code>NSMutableArray</code> and then store this array in <code>NSUserDefaults</code>.</p>
  
  <p>Here is my code :</p>
  
  <pre><code>-(IBAction)onClickSubmitLater:(id)sender
  {
      //Saving store in user defaults for later upload data.
  
      NSMutableArray *arrayStoreList = [[NSMutableArray alloc] init];
      arrayStoreList = [Util getArrayPreference:@"Store"];//arrayStoreList is the list of all stores.
  
      Store *store = [[Store alloc] init];
      store = [arrayStoreList objectAtIndex:self.selectedStoreIndex];//here i am getting particular store that i need to save in array.
  
      //archive
      NSData *dataStore = [NSKeyedArchiver archivedDataWithRootObject:store];
      [[NSUserDefaults standardUserDefaults] setObject:dataStore forKey:@"resultStore"];
  
      //unarchive
      NSData *dataResultStore = [[NSUserDefaults standardUserDefaults] objectForKey:@"resultStore"];
  
      Store *resultStore = (Store *)[NSKeyedUnarchiver unarchiveObjectWithData:dataResultStore];
      NSLog(@"%@", resultStore);
  }
  </code></pre>
  
  <p>Using above code, it is saving single Custom class <code>Store</code> object in <code>NSUserDefaults</code>. So I would like to save all <code>Store</code> object in <code>NSMutableArray</code> after submit later ibaction. Later, I will fetch array of stores for uploading store on server one by one.  </p>
  
  <p>Thanks.</p>