NSInvalidArgumentException原因:data参数为nil

时间:2014-11-10 06:54:09

标签: ios nsdata nsjsonserialization

从服务器获取数据时,我收到以下错误:

NSInvalidArgumentException reason: data parameter is nil

这是我的代码:

- (void)retrieveData
{
    NSURL *url = [NSURL URLWithString:@"http://magmasysdev.com/ddc/getAllCompanies.php"];
    NSData *data = [NSData dataWithContentsOfURL:url];
    jsonArray = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil]; // I'm getting error in this line
}

我想在数组中存储以下响应:

[{"status":"Y"},{"company_data":[{"Company_Id":"5","Company_Name":"SANTE (PVT) LIMITED","Company_Address":"245\/2-Z P.E.C.H.S Block-6 \nKarachi-75400,Pakistan","Company_Email":"sante@sante.com.pk","Company_Tel_Num":"4520507, 4533425","Company_Website":"www.sante.com.pk","Company_Fax_Num":"4.54885e+006"}

链接到我的网络服务:http://magmasysdev.com/ddc/getAllCompanies.php

0 个答案:

没有答案