Store Custom Objects in NSUserDefaults

后端 未结 2 2017
你的背包
你的背包 2021-01-23 22:15

I am trying to store a custom objects as follows, but I am getting an error.

// store data
NSMutableArray *archiveArray = [NSMutableArray arrayWithCapacity:p         


        
2条回答
  •  隐瞒了意图╮
    2021-01-23 23:03

    You unarchive incorrect object. You store NSArray to NSUserDefaults

    NSArray * archiveArray = [userData objectForKey:@"personDataArray"];
    for (NSData *personEncodedObject in archiveArray) {
        id personObject = [NSKeyedUnarchiver unarchiveObjectWithData:personEncodedObject];
    }
    

提交回复
热议问题