4
我想解析一個本地JSON,我試圖這樣做,但是testDict
是零。任何人都可以幫助我嗎?NSDictionary是零
- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
{
[self.searchResult removeAllObjects];
NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"SELF contains[c] %@", searchText];
NSString * firstLetter = [searchText substringWithRange:[searchText rangeOfComposedCharacterSequenceAtIndex:0]];
NSError *err = nil;
NSString *[email protected]"english_";
NSString *updated = [aux stringByAppendingString:firstLetter];
NSString *dataPath = [[NSBundle mainBundle] pathForResource:updated ofType:@"json"];
testDict = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:dataPath] options:kNilOptions error:&err];
JSON是這個樣子:
"Caaba": "(n.) The small and nearly cubical stone building, toward which all Mohammedans must pray.",
"Caas": "(n. sing. & pl.) Case.",
"Cab": [
"(n.) A kind of close carriage with two or four wheels, usually a public vehicle.",
"(n.) The covered part of a locomotive, in which the engineer has his station.",
"(n.) A Hebrew dry measure, containing a little over two (2.37) pints."
],
和我檢查是一個驗證JSON
你可以發佈你嘗試分析請 –
又是什麼'err'告訴你的JSON? – Wain
檢查錯誤! –