Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/114.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
Iphone 如何从NSData获取详细信息_Iphone_Ios_Ios5_Nsdata - Fatal编程技术网

Iphone 如何从NSData获取详细信息

Iphone 如何从NSData获取详细信息,iphone,ios,ios5,nsdata,Iphone,Ios,Ios5,Nsdata,我想从下面的URL获取指定的数据html\u指令。我可以从中获取所有数据 但是我只需要具体的html\u说明。如何分割数据 我使用以下代码将URL转换为NSData: NSString *url = [NSString stringWithFormat:@"http://maps.googleapis.com/maps/api/directions/json?origin=Chennai&destination=Madurai&sensor=false"];

我想从下面的URL获取指定的数据
html\u指令
。我可以从中获取所有数据

但是我只需要具体的
html\u说明。如何分割数据

我使用以下代码将URL转换为NSData:

 NSString *url = [NSString      stringWithFormat:@"http://maps.googleapis.com/maps/api/directions/json?origin=Chennai&destination=Madurai&sensor=false"];
    NSURL *googleRequestURL=[NSURL URLWithString:url];
    dispatch_async(kBgQueue, ^{
    NSData* data = [NSData dataWithContentsOfURL: googleRequestURL];
    });
将其用作:

    NSData* data = [NSData dataWithContentsOfURL:googleRequestURL];
    if (data == nil) {
        return;
    }
    NSError* error;
    NSMutableDictionary* json = [NSJSONSerialization
                                 JSONObjectWithData:data

                                 options:kNilOptions
                                 error:&error];

    NSLog(@"Json : %@",json);
希望它能帮助您。

将其用作:

    NSData* data = [NSData dataWithContentsOfURL:googleRequestURL];
    if (data == nil) {
        return;
    }
    NSError* error;
    NSMutableDictionary* json = [NSJSONSerialization
                                 JSONObjectWithData:data

                                 options:kNilOptions
                                 error:&error];

    NSLog(@"Json : %@",json);

希望对您有所帮助。

我从以下url解析了json,并打印了html说明。请复制此代码,然后重试:

NSData*receivedData=从url接收的数据;
n错误*错误;
NSMutableDictionary*parsedJson=[NSJSONSerialization JSONObjectWithData:receiveData选项:编织错误:&error];
NSArray*allkeys=[parsedJson allkeys];
对于(int i=0;i
我从以下url解析了json,并打印了html说明。请尝试复制此代码并重试:

NSData*receivedData=从url接收的数据;
n错误*错误;
NSMutableDictionary*parsedJson=[NSJSONSerialization JSONObjectWithData:receiveData选项:编织错误:&error];
NSArray*allkeys=[parsedJson allkeys];
对于(int i=0;i
感谢您的rply nishant。但Json也显示URL中的所有数据。需要指定的“html_指令”数据时,请仅从URl.thanksthanks获取您的rply nishant。但Json也显示URL中的所有数据。需要指定的“html_说明”数据时,请仅从URl.Thankstory获取,以免打扰您。我在“你的钥匙”处给出了“html_说明”。但是它显示为空。你可以发布parsedJson吗?哪一个是空的?很抱歉,这是我的测试变量,所以请用ParsedJSON替换它。非常感谢jailani。因为你,我无法控制我的快乐。非常感谢,谢谢。jailani我如何在表中存储此值。请帮助我。抱歉打扰您。我在“你的钥匙”处给出了“html_说明”。但是它显示为空。你可以发布parsedJson吗?哪一个是空的?很抱歉,这是我的测试变量,所以请用ParsedJSON替换它。非常感谢jailani。因为你,我无法控制我的快乐。非常感谢,谢谢。jailani我如何在表中存储此值。请帮助我。