tags:

views:

150

answers:

1

Possible Duplicate:
How to store custom objects in NSUserDefaults

HI, How can i store NSMutable array in NSUserDefaults? regards shishir

A: 

Storing the array is as easy as:

NSMutableArray *array = [NSMutableArray array];
[[NSUserDefaults standardUserDefaults] setObject:array forKey:@"array"];

but every object in the array must be a property-list object. That is, they must be one of:

  • NSArray
  • NSDictionary
  • NSString
  • NSData
  • NSDate
  • NSNumber

If you want to store instances of other classes in a property list, you must create methods to serialize/deserialize them to and from one of these types. Serializing objects to dictionaries is a common approach.

EDIT: Another approach is shown here: How to store custom objects in NSUserDefaults

Can Berk Güder
this is not working for me sir,i m inserting objects into an array,and i want that array should be in NSUserdefault. regardsshishir
shishir.bobby