Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/110.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
Wcf rest服务获取和发布iOS_Ios_Objective C_Wcf_Rest - Fatal编程技术网

Wcf rest服务获取和发布iOS

Wcf rest服务获取和发布iOS,ios,objective-c,wcf,rest,Ios,Objective C,Wcf,Rest,我的朋友为我的应用程序写了一个服务。这里是链接http://213.155.113.51/cronos/medconcept/services/v3/iOSServices.svc/productsget ,这是测试链接。我只是想弄到绳子。我尝试了这篇文章,但是Json是空的 这是我代码的一部分 NSString *request = [NSString stringWithFormat:@"link here"]; NSURL *URL = [NSURL URLWithString:

我的朋友为我的应用程序写了一个服务。这里是链接http://213.155.113.51/cronos/medconcept/services/v3/iOSServices.svc/productsget ,这是测试链接。我只是想弄到绳子。我尝试了这篇文章,但是Json是空的

这是我代码的一部分

NSString *request = [NSString stringWithFormat:@"link here"];
NSURL *URL = [NSURL URLWithString:
              [request stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSError *error = nil;
NSData *data = [NSData dataWithContentsOfURL:URL options:NSDataReadingUncached error:&error];

NSLog(@"data = %@",data);

if(!error)
{
    NSDictionary *json = [NSJSONSerialization
                          JSONObjectWithData:data
                          options:NSJSONReadingMutableContainers
                          error:&error];

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

    NSMutableArray *array= [json objectForKey:@"GetUserResult"];

    NSLog(@"array = %@",array);
    /*
    for(int i=0; i< array.count; i++)
    {
        NSDictionary *userInfo= [array objectAtIndex:i];
        NSInteger *id = [userInfo objectForKey:@"ID"];
        NSString *name = [userInfo objectForKey:@"NAME"];
        NSString *surname = [userInfo objectForKey:@"SURNAME"];
        NSLog(@"ID: %d NAME: %@ SURNAME: %@", id,name,surname);
    } 
     */
}
输出:Json=null 数组=空

我做错了什么?或者您知道获取和发布字符串的其他方法吗


感谢您的关注和建议。

为什么不打印错误的内容?-数据是否已为零?数据的输出-->数据=如果json为零,则在json解析后打印错误内容。以下是错误打印->错误=错误域=NSCOCAERRORDOMAIN代码=3840操作无法完成。可可错误3840。JSON文本不是以数组或对象和允许未设置片段的选项开头的。UserInfo=0x8a60240{NSDebugDescription=JSON文本没有以数组或对象以及允许未设置片段的选项开头。}但我不理解。我需要做什么?可能重复-您的服务器发送嵌套JSON。