我有一个问题,我不明白发生了什么。它在一小时前工作,然后停止工作,我不明白为什么。:秒
您能否将此 JSON 添加到本地主机上的文件夹中并尝试这段代码。那你能告诉我你的 NSLOG 打印的东西是否比这更好:
2012-05-16 11:18:21.996 WonderBox[51241:fb03] JSON : (null)
NSString *urlString = [NSString stringWithFormat:@"http://localhost:8888/WonderBox/json.txt"];
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:urlString]];
NSError *err;
NSMutableArray *json = (NSMutableArray* )[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&err];
NSLog(@"JSON : %@", json);
我的 JSON:
{
"boxesDetail": [
{
"name": "NAME1",
"number": "12",
"sexe": "female",
"topic": "Bien-être",
},
{
"name": "NAME2",
"number": "33",
"sexe": "couple",
"topic": "Bien-être",
},
{
"name": "NAME3",
"number": "43",
"sexe": "female",
"topic": "Gastronomie",
},
{
"name": "NAM E4",
"number": "33",
"sexe": "couple",
"topic": "Adventure",
},
{
"name": "NAME5",
"number": "102",
"sexe": "group",
"topic": "Gastronomie",
},
{
"name": "NAME6",
"number": "40",
"sexe": "male",
"topic": "Sport",
},
{
"name": "NAME7",
"number": "12",
"sexe": "male",
"topic": "Sport",
}
]
}