Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php mysql与objective c通信(接收数据)_Php_Ios_Mysql_Objective C_Json - Fatal编程技术网

Php mysql与objective c通信(接收数据)

Php mysql与objective c通信(接收数据),php,ios,mysql,objective-c,json,Php,Ios,Mysql,Objective C,Json,我正在php、mysql和objective c之间进行通信。我使用Json从php文件接收数据。问题是,我只从php文件接收第一条数据。我试图创建一个for循环,但只打印了5次第一次接收的数据(这是数据库中的数据数量)。我不知道该怎么办,请帮忙。下面是我的代码: -(void) getData:(NSData *) data{ NSError *error; json = [NSJSONSerialization JSONObjectWithData:data options

我正在php、mysql和objective c之间进行通信。我使用Json从php文件接收数据。问题是,我只从php文件接收第一条数据。我试图创建一个for循环,但只打印了5次第一次接收的数据(这是数据库中的数据数量)。我不知道该怎么办,请帮忙。下面是我的代码:

-(void) getData:(NSData *) data{
    NSError *error;

    json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptionserror:&error];
}

-(void) start{
    NSURL *url = [NSURL URLWithString:kGETUrl];
    NSData *data = [NSData dataWithContentsOfURL:url];
    [self getData:data];

    //NSLog(@"Test:", data);

    NSIndexPath *indexPath;
    NSDictionary *info = [json objectAtIndex:indexPath.row];
    //int *num = [json count];

    for(NSString* key in info){
        NSLog([info objectForKey:@"title"]);
    }
}

为什么不在
for
循环中使用
变量?而
indepath
变量在使用时为零。。。你从
NSLog(“%@”,json)中得到了什么?我会尝试一下,然后告诉你,当我这样做时,它会打印出数据库中的所有内容,但格式很奇怪:body=testing;日期=“2015-04-26”;id=20;tags=tag1;title=title1;}看起来像这样。我只想把标题和正文打印出来,而不是像这样的奇怪格式