안녕하세요 나는이처럼 보이는 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에가 위도 와 y 값 52.50707112779077에 대한 5.968097965285907 값이 필요
[__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)
01 : 경도
는하지만 난이 오류가
행을 선택해야하는 사람이 있습니까?
유일한 문제는 행 번호를 변경해야한다는 것입니다. 아니면 다음과 같은 것이 있어야합니다 : [1] [5]. 임이
"json that looks like this"를 사용하면 json이 유효하지 않습니다. 그것은 단지 NSDictionary 기술입니다. – erkanyildiz
나는이 JSON이 유효하지 않으며, 실제 JSON을 게시한다. (그리고 먼저 jsonlint.com에서 확인한다.) – borrrden
아니, 나는 json을 얻지 만, 다음과 같이한다. NSArray * data = [root objectForKey : @ "features"]; 그리고 나서 NSArray를 얻습니다. 내가 잘못 말했다면 –