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 使用C#,asp.net读取Excel文件并保存到Oracle数据库
    • ¥15 C# datagridview 单元格显示进度及值
    • ¥15 thinkphp6配合social login单点登录问题
    • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 虚心请教几个问题,小生先有礼了
    • ¥30 截图中的mathematics程序转换成matlab