doudou1309 2013-09-25 18:14
浏览 32

无法从PHP文件接收json数据

My PHP Script:

$result = mysql_query('Select * FROM _events');
$rows = array();
  while($r = mysql_fetch_assoc($result)) 
     {
     $rows['results'][] = $r;
     }

print json_encode($rows);

Result:

{"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"}]}

My Problem is now that my Xcode iOS App cant receive the data ?

  - (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];

}

I dont see there any problems? Can somebody help me? The Xcode Error says:

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 uncaught exception of type NSException (lldb)

???

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
    • ¥20 关于URL获取的参数,无法执行二选一查询
    • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
    • ¥15 marlin编译错误,如何解决?
    • ¥15 有偿四位数,节约算法和扫描算法
    • ¥15 VUE项目怎么运行,系统打不开
    • ¥50 pointpillars等目标检测算法怎么融合注意力机制
    • ¥20 Vs code Mac系统 PHP Debug调试环境配置
    • ¥60 大一项目课,微信小程序
    • ¥15 求视频摘要youtube和ovp数据集