来自json的responseString解析为nil

时间:2015-09-07 06:49:13

标签: ios objective-c json parsing

我想从soundcloud给出的url中解析一个json。

     NSURL *url = [NSURL URLWithString:test[indexPath.row]];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];

    NSURLResponse *response = NULL;
    NSError *requestError = NULL;
    NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&requestError];




     NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
        NSData* jsonData = [responseString dataUsingEncoding:NSUTF8StringEncoding];

        NSError *jsonError;
        NSDictionary* allKeys = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONWritingPrettyPrinted error:&jsonError];

Url有这种形式:

https://api.soundcloud.com/tracks/195677713/stream?client_id=3e6cb435319c6fdaad56ff5641e0f89e

但是responseString是零。

任何想法为什么?

0 个答案:

没有答案