我的PHP脚本:
$result = mysql_query('Select * FROM _events');
$rows = array();
while($r = mysql_fetch_assoc($result))
{
$rows['results'][] = $r;
}
print json_encode($rows);
结果:
{"results":[{"id":"1","title":"Night Run","url":"http:\/\/www.orf.at","date":"01.10.2013"},
{"id":"2","title":"Silvester","url":"http:\/\/www.sms.at","date":"31.12.2013"}]}
我的问题是我的Xcode iOS App无法接收数据?
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"Ergebnisse";
dispatch_async(kBgQueue, ^{
NSData* data = [NSData dataWithContentsOfURL:
kjsonURL];
[self performSelectorOnMainThread:@selector(fetchedData:)
withObject:data waitUntilDone:YES];
});
}
- (void)fetchedData:(NSData *)responseData {
NSError* error;
NSDictionary* json = [NSJSONSerialization
JSONObjectWithData:responseData
options:kNilOptions
error:&error];
ergebnisse = [json objectForKey:@"results"];
[self.tableView reloadData];
}
我没有看到有任何问题?有人能帮助我吗? Xcode错误说:
由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'data parameter is nil' * 第一次抛出调用堆栈: (0x30780ed3 0x3a7a96c7 0x30780e15 0x310ea267 0xe8f61 0x311464cb 0x3074bf27 0x3074b3ef 0x30749bdf 0x306b4541 0x306b4323 0x35148343 0x32ccd7b5 0xea015 0x3acbeab7) libc ++ abi.dylib:以NSException类型的未捕获异常终止 (lldb)
???