//聯(lián)系人:石虎QQ: 1224614774昵稱(chēng):嗡嘛呢叭咪哄
在使用NSUserDefaults的時(shí)候插入數(shù)據(jù)有時(shí)候會(huì)報(bào)以下錯(cuò)誤:
Attempt to set a non-property-list object {type = immutable dict, count = 27,
entries =>
3 : ext_attr = {contents = ""}
4 : zhicheng = {contents = ""}
5 : code = {contents = "YS1000000000011"}
6 : zhuzhi = {contents = ""}
10 : sex = {contents = ""}
14 : cat_id = {contents = ""}
15 : pass = 123123
16 : keshi =
18 : name = {contents = "新醫(yī)生"}
19 : sp = {contents = ""}
20 : moreinfo = {contents = ""}
21 : state = {contents = ""}
22 : {contents = "comment_num"} = 0
23 : id = 11
25 : p_attr = {contents = ""}
26 : pcolumn = 1
27 : pic = {contents = "http://58.61.37.228:3080/td_yisheng/static/img/photo.gif"}
28 : {contents = "zhizhaopic"} = {contents = ""}
29 : mobile = {contents = "18682355562"}
30 : showtpl = 1
31 : email = {contents = ""}
32 : area = {contents = "區(qū)域"}
33 : uptime = {type = immutable, count = 1, values = (
0 : {contents = ""}
)}
36 : price = {type = immutable dict, count = 5,
entries =>
2 : baoyue = 1
3 : dianhua = 1
4 : huizhen = 1
5 : yuyue = 1
6 : zixun = 1
}
38 : {contents = "comment_rank"} = 5
39 : regtime = {contents = "1442394762"}
40 : patchcode = {contents = ""}
}
as an NSUserDefaults/CFPreferences value for key UserModelDic
這種錯(cuò)誤的原因是插入了不識(shí)別的數(shù)據(jù)類(lèi)型穷躁,NSUserDefaults支持的數(shù)據(jù)類(lèi)型有NSString氯庆、 NSNumber歼指、NSDate、 NSArray、NSDictionary、BOOL、NSInteger、NSFloat等系統(tǒng)定義的數(shù)據(jù)類(lèi)型垄开。
自定義的類(lèi)型需要轉(zhuǎn)成NSData再存入。
===============================================
我原來(lái)認(rèn)為NSUserDefaults存不了數(shù)組税肪,又換成了字典溉躲,但是還是報(bào)錯(cuò),最后求助網(wǎng)友大神解決了益兄,是我里邊的數(shù)據(jù)結(jié)構(gòu)有""锻梳,而NSUserDefaults是不能被成功解析并存入的,所有在存入之前需要將里邊的""改成""即可净捅。
謝謝!!!