可能重複:
Storing custom objects in an NSMutableArray in NSUserDefaults
How to store custom objects in NSUserDefaults如何將對象添加到NSMutableArray中以存儲在NSUserDefaults中?
我試圖存儲從一個類實例化一個對象我編寫的名爲 「動物」 在一個NSMutableArray存儲在NSUserDefaults的。但是,我得到這個錯誤。
[NSUserDefaults setObject:forKey:]: Attempt to insert non-property value '(
"<Animal: 0xcea7060>"
)' of class '__NSArrayM'. Note that dictionaries and arrays in property lists must also contain only property values.
這是什麼意思?也許我不能將對象存儲在NSMutableArrays中以存儲在NSUserDefaults中?
的可能重複[如何在存儲NSUserDefaults的自定義對象(http://stackoverflow.com/q/2315948/);也http://stackoverflow.com/q/7459585/,http://stackoverflow.com/q/537044/和http://stackoverflow.com/q/471830/ – 2012-04-12 19:48:28