How to use arrayWithContentsOfFile to load file successfully written with writeToFile in ObjectiveC/XCode

后端 未结 2 436
孤街浪徒
孤街浪徒 2021-01-18 06:42

I am saving an array of custom objects to a plist list file like so:

+(void) arrayToPlist: (NSArray*) plant_types{
    NSMutableArray* dictionary_array = [NS         


        
2条回答
  •  忘掉有多难
    2021-01-18 07:15

    This line:

    NSMutableDictionary* dict = [plant_dicts objectAtIndex: i];
    

    does not return a mutable dictionary, but an immutable one.

    If you want it to be mutable, you should do something along these lines:

    MutableDictionary* dict = [NSMutableDictionary dictionaryWithDictionary: [plant_dicts objectAtIndex: i]];
    

提交回复
热议问题