我的目标 C 代码有问题,我收到这些错误。
2013-01-31 16:22:53.611 iSA-MP[541:c07] -[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x7465d70
2013-01-31 16:22:53.614 iSA-MP[541:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary objectAtIndex:]: unrecognized selector sent to instance 0x7465d70'
*** First throw call stack:
(0x1c8c012 0x10c9e7e 0x1d174bd 0x1c7bbbc 0x1c7b94e 0x2163 0xf2817 0xf2882 0x41a25 0x41dbf 0x41f55 0x4af67 0xefcc 0xffab 0x21315 0x2224b 0x13cf8 0x1be7df9 0x1be7ad0 0x1c01bf5 0x1c01962 0x1c32bb6 0x1c31f44 0x1c31e1b 0xf7da 0x1165c 0x1dbd 0x1ce5)
libc++abi.dylib: terminate called throwing an exception
使用此代码:
NSString *urlString = [NSString stringWithFormat:@"http://192.168.0.125:100/isa-mp/iSA-MP.php?serverIP=192.168.0.125&serverPort=7777"];
NSURL *url = [NSURL URLWithString:urlString];
NSData *data = [NSData dataWithContentsOfURL:url];
NSError *error;
NSMutableArray *array = (NSMutableArray*)[NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSLog(@"%@", [array objectAtIndex:0]);