基本上我有一个 NSdictionaries 数组,我想将它们存储在 NSUserDefaults 中。pageDict 是本地 NSDictionary LyteData 是用于存储内容的 Singleton 类 层次结构来自 lyteData.textbookDictArray ---> lyteData.pagesDictArray ---> pageDict (NSDictionary)
[pageDict setObject:textbookImage forKey:@"image"];
[pageDict setObject:textbookName forKey:@"name"];
[pageDict setObject:page forKey:@"page"];
[pageDict setObject:nameOfClass forKey:@"class"];
LyteData *lyteData = [LyteData sharedManager];
[lyteData.pagesDictArray addObject:pageDict];
[lyteData.textbookDictArray addObject:lyteData.pagesDictArray];
NSLog(@"array: %@", lyteData.pagesDictArray);
NSLog(@"textbook array: %@", lyteData.textbookDictArray);
//THIS CODE IS FOR SAVING THE ARRAY OF TEXTBOOKS AS USERDEFAULT
[[NSUserDefaults standardUserDefaults]
setObject:lyteData.textbookDictArray forKey:@"textbookArray"];
我收到此错误:
Attempt to set a non-property-list object (
{
class = hb;
image = "<UIImage: 0x165c43d0>";
name = fv;
page = 25;
}
) as an NSUserDefaults value for key textbookArray
如何将该数组存储在 NSUserDefaults 中?