當前位置:成語大全網 - 書法字典 - IOS開發,JSON已經解決,如何獲取裏面的內容?

IOS開發,JSON已經解決,如何獲取裏面的內容?

1,首先獲取文件目錄。

NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);

ns string * documents directory =【paths objectAtIndex:0】;

chat file =【【ns string alloc】init with string:【documents directory stringByAppendingPathComponent:chats file _ NAME】;

2.加載文件

-(void)load thread:(ns string *)xmlFile {

nsautorelaespool * pool =【【nsautorelaespool alloc】init】;

nsxml parser * chatLogParser =【【nsxml parser alloc】initwithcontentsourl:【NSURLfileURLWithPath:xmlFile】】;

【chatLogParser set delegate:self】;

【current string set string:@““】;//記錄當前節點的值

【currentChatInfo remove all objects】;//節點對象

【chatLogParser解析】;//開始XML解析

chatLogParser發布】;

【self performSelectorOnMainThread:@ selector(finshLoadFile)with object:nil waitildone:YES】;//創建線程

【池釋放】;

}