Search code examples
iosobjective-cplistnsorderedset

iOS: How to save NSOrderedSet with app related user data?


I need to save NSOrderedSet as a container for an inner NSDictionary objects. I tried to save the set to plist, but this class can't be saved here. Are there any other way to save it easily and don't go to Core Data jungle?


Solution

  • Save the ordered set as an array:

    NSOrderedSet *set = ... // your ordered set
    NSArray *array = [set array];
    // Now write the array to the plist
    

    Later,

    // read the array from the plist
    NSArray *array = ... // array from plist
    NSOrderedSet *set = [NSOrderedSet orderedSetWithArray:array];