1

I'm encoding some NSDictionary with NSCoder and I want to save it somehow inside the app. Could anyone please tell me how I could do it?

I want to give the user the ability to see what he's done previously when he opens the app.

vikingosegundo
  • 52,040
  • 14
  • 137
  • 178
Sorin Cioban
  • 2,237
  • 6
  • 30
  • 36

1 Answers1

1

You can write it to a file in your Application Support folder or, if it's small, you can put it into NSUserDefaults. For either of those, though, if the dictionary contains only property list types, you can write the dictionary directly. You don't have to encode it to an NSData first.

Ken Thomases
  • 88,520
  • 7
  • 116
  • 154
  • 1
    You can only encode the contents of a dictionary to user defaults directly if every object in the "object graph" of the dictionary (the objects in the dictionary and any objects those objects contain, all the way down to the end of each branch) are "property list objects" (NSString, NSData, NSDate, NSNumber, NSArray, or NSDictionary objects). – Duncan C May 14 '12 at 02:10