0

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?

4
  • 1
    What does the compiler complain about? Commented Oct 13, 2010 at 16:43
  • It says "Attempt to insert non-property value." Commented Oct 13, 2010 at 17:52
  • 1
    Take a look at this question: stackoverflow.com/questions/471830/… Commented Oct 13, 2010 at 19:47
  • I found my answer over there. Commented Oct 13, 2010 at 21:16

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

My problem is: can you turn it back into a Mutable array, add stuff to it then save it back to NSUserDefaults??
@RafaelMoreira the thing is probably not mutable when you get it, but you can always do mutableCopy

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.