How to store NSMutableArray in NSUserDefaults

Please tell me how I can store NSMutableArrayin NSUserDefaults.

I have an array called data ( NSArray). I want to add this array to NSMutableArray, called mArray.

[mArray addObject:data];
[prefs setObject:mArray forkey:@"test"];
[prefs synchronize];

& want to save values mArrayto NSUserDefaults. Please tell me how I can store and retrieve these values. The above code only stores the last value, not adding the value to NSUserDefaults.

thank

+5
source share
1 answer

You can not. See http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSUserDefaults_Class/Reference/Reference.html in particular:

, NSUserDefaults , . , "MyStringDefault", , , stringForKey: .

mutableCopy , NSUserDefaults, , .

+21

All Articles