【iOS開發】檔案寫入沙盒失敗
阿新 • • 發佈:2019-02-17
把伺服器返回資料寫入沙盒,在沙盒中找不到程式碼如下:
[responseObject writeToFile:path atomically:YES];
然後查了下返回值,發現寫入資料失敗。
BOOL success = [responseObject writeToFile:path atomically:YES];
返回值為NO
查閱文件結果:returns NO if all the objects are not property list objects, since the resultant file would not be a valid property list.
說明如果要儲存的物件中如果包含有非 屬性列表物件(plist物件),就會儲存失敗。
plist支援的資料型別有:Foundation框架中得資料型別NSNumber,NSString,
NSDate,NSArray,NSDictionary,BOOL, NSData。並且屬性列表的根目錄只能為NSDictionary或者NSArray。
plist檔案通常用於儲存使用者設定,也可以用於儲存捆綁的資訊,其內容為xml格式。它可以在程式執行期間動態的建立和讀寫,因此可以用於少量資料時候的資料持久化。