plist文件:the data couldn't be read because it isn't in the correct format 問題

在使用plist文件做本地緩存時(shí),由于是通過代碼創(chuàng)建的,在使用的過程中遇到了the data couldn't be read because it isn't in the correct format問題,

Google了一下,發(fā)現(xiàn)沒有想要的答案便自己查代碼解決。在使用plutil xxx.plist終端命令時(shí) 得到下面信息xxx.plist: Cannot parse a NULL or zero-length data。


原來代碼創(chuàng)建plist文件,在沒有進(jìn)行數(shù)據(jù)存儲的時(shí)候,是一個(gè)空的文件,在你雙擊打開時(shí)是會出現(xiàn)the data couldn't be read because it isn't in the correct format的提示的。這不是你代碼的問題,只是plist里面沒有數(shù)據(jù)而已。但在使用plist存儲數(shù)據(jù)時(shí),如果使用了非法類型的數(shù)據(jù)你一樣是不能進(jìn)行存儲的。所以,再用plist時(shí)要保證你的數(shù)據(jù)類型合法(dictionary,array,data,date,bool,number,string)。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容