json檔案解析出現異常

2021-07-02 21:33:46 字數 818 閱讀 2740

今天在嘗試用自帶的

問題如下:

**:

nsstring *newcoursepath = [[nsbundle mainbundle] pathforresource:@"addcourses" oftype:@"json"];

nsdata *data = [nsdata datawithcontentsoffile:newcoursepath];

nsarray *array = [nsjsonserialization jsonobjectwithdata:data options:nsjsonreadingallowfragments error:nil];

_coursesarray = [[nsmutablearray alloc] init];

經除錯發現,在**

nsarray *array = [nsjsonserialization jsonobjectwithdata:data options:nsjsonreadingallowfragments error:nil];
處,出現異常!

異常如下:

表明,**中從addcourse.json中獲取的資料data為空!

然後我先排查了json檔案中可能存在的格式錯誤,發現異常仍然出現。

而json檔案確實新增到了工程中。

於是,只好把工程中的json檔案,移除,嘗試再次新增,這就發現了問題!

把檔案拖至工程的相應檔案中,會彈出如下選項卡:

所以如果直接新增,實際上這個json檔案並沒有得到有效新增!

異常排除~

service stop時出現異常

sbin service line 66 23299 terminated env i lang lang path path term term 原因是 我把管理指令碼的名稱設為和後台程序名稱一樣,即 後台程序名稱 deamon name,指令碼名稱 etc init.d deamon name ...

OSS 上傳出現異常

分析 有明顯報錯資訊的先 google 一下,看看是作業系統錯誤還是 ossbrower 丟擲,經過鑑定錯誤是 linux 系統底層返回,說明當時系統的 ossbrower 所在的目錄磁碟滿了,開源的錯誤到處可以看到,自行解決即可。分析 如果分片上傳成功,肯定不會出現訪問 404 的情況,檢查下 i...

python打包exe出現異常

python使用pyinstaller打包exe出現異常 fatal python error initfsencoding unable to load the file system codec zipimport.zipimporterror can t find module encodin...