I was able to save an NSMutableArray of custom objects to NSUserDefaults by implementing NSCoding in the custom class. However, now I want to save an NSMutableArray of these arrays. The compiler complains when I try to do this. How can this be done?
Asked
Active
Viewed 1,072 times
0
-
1What does the compiler complain about? – Nick Moore Oct 13 '10 at 16:43
-
It says "Attempt to insert non-property value." – node ninja Oct 13 '10 at 17:52
-
1Take a look at this question: http://stackoverflow.com/questions/471830/why-nsuserdefaults-failed-to-save-nsmutabledictionary-in-iphone-sdk – Nick Moore Oct 13 '10 at 19:47
-
I found my answer over there. – node ninja Oct 13 '10 at 21:16
1 Answers
1
I found out how to do it. Basically, your transform the array into a data object using NSKeyedArchiver, and that is what you save with NSUserDefaults. Then when you get the data object back, you use NSKeyedUnarchiver to turn it back into an array.

node ninja
- 31,796
- 59
- 166
- 254
-
My problem is: can you turn it back into a Mutable array, add stuff to it then save it back to NSUserDefaults?? – Rafael Moreira Feb 16 '12 at 01:27
-
@RafaelMoreira the thing is probably not mutable when you get it, but you can always do `mutableCopy` – Dan Rosenstark Aug 20 '15 at 19:05