你好,我得到一個JSON看起來像這樣:從NSArray的
features: (
{
attributes = {
Gecontroleerd = Ja;
};
geometry = {
x = "5.968097965285907";
y = "52.50707112779077";
};
}
)
從這個代碼:
NSDictionary *root = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:nil];
NSArray *data = [root objectForKey:@"features"];
NSLog(@"features: %@", data);
for (NSArray *row in data) {
NSString *latitude = row[5];
NSString *longitude = row[7];
NSString *crimeDescription = @"test";
NSString *address = @"banaan";
和U需要X值5.968097965285907緯度 和y的值52.50707112779077爲經度
但我得到這個錯誤:
[__NSCFDictionary objectAtIndexedSubscript:]: unrecognized selector sent to instance 0x14831450
2012-11-14 10:10:59.000 ArrestPlotter[6330:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary objectAtIndexedSubscript:]: unrecognized selector sent to instance 0x14831450'
*** First throw call stack:
(0x1860012 0x1655e7e 0x18eb4bd 0x184fbbc 0x184f94e 0x2dbc 0x3b8f 0x1cc1e 0x16696b0 0xfa0035 0x17e3f3f 0x17e396f 0x1806734 0x1805f44 0x1805e1b 0x224a7e3 0x224a668 0x4a765c 0x25bd 0x24e5 0x1)
libc++abi.dylib: terminate called throwing an exception
(lldb)
有沒有人我需要選擇?
我想唯一是行號需要改變。或者也許應該是這樣的:[1] [5]。我不是很確定這是如何工作
如果你真的「得到一個看起來像這樣的json」,那麼你的json是無效的。這只是一個NSDictionary描述。 – erkanyildiz
我同意,這個JSON是無效的,張貼實際的JSON(並驗證它在jsonlint.com第一) – borrrden
沒有我得到一個JSON,但我這樣做:NSArray * data = [root objectForKey:@「features」];然後我得到NSArray .. 對不起,如果我說錯了 –