0

我的 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 错误说:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'data parameter is nil' * First throw call stack: (0x30780ed3 0x3a7a96c7 0x30780e15 0x310ea267 0xe8f61 0x311464cb 0x3074bf27 0x3074b3ef 0x30749bdf 0x306b4541 0x306b4323 0x35148343 0x32ccd7b5 0xea015 0x3acbeab7) libc++abi.dylib: terminating with NSException (lldb) 类型的未捕获异常

???

4

0 回答 0