将NSMutableArray存储到NSUserDefaults

时间:2017-04-05 05:19:58

标签: ios objective-c nsmutablearray nsuserdefaults

我正在尝试将NSMutableArray存储到NSUserDefaults中,如下所示,但会收到以下错误。

(lldb) po pOrderElements
<__NSArrayM 0x174256b90>(
{
    category = 1;
    imagePath = "products/chicken-kabob.png";
    name = "Baked Chicken";
    price = "5.49";
}
)

NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:pOrderElements forKey:@"tableViewData"];
[userDefaults synchronize];
  

由于未捕获的异常而终止应用   'NSInvalidArgumentException',原因:'尝试插入非属性   列表对象(           {           category = 1;           id =“”;           imagePath =“products / chicken-kabob.png”;           name =“烤鸡”;           price =“5.49”;       })for key tableViewData'

0 个答案:

没有答案