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?
-
1What does the compiler complain about?Nick Moore– Nick Moore2010-10-13 16:43:06 +00:00Commented Oct 13, 2010 at 16:43
-
It says "Attempt to insert non-property value."node ninja– node ninja2010-10-13 17:52:50 +00:00Commented Oct 13, 2010 at 17:52
-
1Take a look at this question: stackoverflow.com/questions/471830/…Nick Moore– Nick Moore2010-10-13 19:47:53 +00:00Commented Oct 13, 2010 at 19:47
-
I found my answer over there.node ninja– node ninja2010-10-13 21:16:08 +00:00Commented Oct 13, 2010 at 21:16
Add a comment
|
1 Answer
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.
2 Comments
Rafael Moreira
My problem is: can you turn it back into a Mutable array, add stuff to it then save it back to NSUserDefaults??
Dan Rosenstark
@RafaelMoreira the thing is probably not mutable when you get it, but you can always do
mutableCopy