由于實(shí)驗(yàn)室項(xiàng)目的需要將數(shù)據(jù)存入plist双霍,遇到了無(wú)法將數(shù)據(jù)寫入plist的情況描姚,現(xiàn)在將遇到的兩種問題以及解決方法瓶珊。
1>.在iOS中栅屏,只允許向沙盒中的plist文件寫數(shù)據(jù)
The problem is you are trying to write to a file in the bundle. The only places you are allowed to write to are the caches directory (not what you want) and the documents directory.(http://stackoverflow.com/questions/32807098/cant-write-data-to-plist-in-ios)
2>.當(dāng)向沙盒中的plist文件寫數(shù)據(jù)無(wú)效時(shí)
writeToFile:atomically:
對(duì)寫入的數(shù)據(jù)結(jié)構(gòu)應(yīng)屬于以下幾種如下:
NSString
NSData
NSDate
NSNumber
NSArray
NSDictionary
其他的數(shù)據(jù)結(jié)構(gòu)是不被接受的飘千,如 null(http://stackoverflow.com/questions/3010363/nsarray-writetofile-fails)