从目标c中的api获得了空值

时间:2018-07-28 10:27:08

标签: ios objective-c json

我正在从API提取JSON值...但是它将值显示为null ...我在邮递员那里检查了它的工作原理并得到了回应...我在下面列出了我的示例代码我的错。我是这个开发的新手

- (IBAction)PaymentButtonTapped:(id)sender {
    [self PayuMoneyAdminValues];
}


-(void)PayuMoneyAdminValues{
    NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc]init];
    NSString *urlstring = [NSString stringWithFormat:@"%@admindatas",restSiteURLServices];
    NSURL *url = [NSURL URLWithString:urlstring];
    NSString *userUpdate = [NSString stringWithFormat:@"%@",restAuth];
    [urlRequest setHTTPMethod:@"POST"];
    [urlRequest setURL:url];
        //Convert the String to Data
    NSData *data1 = [userUpdate dataUsingEncoding:NSUTF8StringEncoding];
        //NSData *data1 =  [NSData dataWithContentsOfURL:url];
        //Apply the data to the body
    [urlRequest setHTTPBody:data1];

    NSURLSession *session = [NSURLSession sharedSession];
    NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:urlRequest completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
        if(data!=nil){
            NSError *parseError = nil;
            NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
            if (parseError) {
                NSLog(@"Admin data: %@",responseDictionary);
            }
        }
    }];
    [dataTask resume];
    }

0 个答案:

没有答案