有什麼辦法讓NSLog打印出一個完整的JSON文件。我現在說Xcode如何NSLog一個JSON
NSString *deviceInfo = [NSString stringWithFormat:@"%@ %@",
[[UIDevice currentDevice]model], [[UIDevice currentDevice]systemVersion]];
NSDictionary *json = [deviceInfo JSONValue];
NSLog(@"json file = %@", json);
而且它打印出「JSON文件=(空)」
感謝 克林頓
非常感謝你的工作。它目前正在打印出這個'{「deviceModel」:「iPod touch」,「deviceSystemVersion」:「4.3.5」},如果我想在每個硬件外部有多個塊和某些東西, :{「deviceModel」:「iPod touch」}「os」:{「deviceSystemVersion」:「4.3.5」}'我該怎麼做。 –
只要嵌套字典。 '[NSDictionary dictionaryWithObjectsAndKeys:someDictionary,@「someKey」,someOtherDictionary,@「someOtherKey」,零]' –
是的工作。還有一件事是。我似乎無法改變NSDictionary中的順序。我有'NSDictionary * fullJSON = [NSDictionary dictionaryWithObjectsAndKeys:hardware,@「hw」,os,@「os」,nil];'但是它打印出了{{{「os」:{「ver」:「4.3.5」 },「hw」:{「model」:「iPod touch」}}'我不認爲它是必要的,但如果我能夠使硬件成爲第一,那將會很好。 –