-2
我有一個問題,我不明白是怎麼回事。它在一小時前工作,然後停止工作,我不明白爲什麼。 :s從JSON填充NSMutableArray - Empty = o
您能否將此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);
MY 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",
}
]
}
有一個昏迷,我發現問題:「名稱」:「NAM E4」,有一個空間,它不工作..但它很奇怪......爲什麼?它應該與空間... – user1256827
找到答案...這是一個選項卡://對不起,男人! – user1256827