我的json响应是这样的..

{
sentdetails =     (
            {
        coursename = "Course Two";
        createddate = "05/12/2015 06:13 AM";
        currentprice = "2.00";
        "no_of_files" = 9;
        queryid = 36;
        querystatus = Open;
        submissionid = TSAb13d585e;
        testsaviornotes = None;
        title = Test;
        usernotes = rdgbv;
    }
);
status = Sucess;}

现在,我尝试将json数据(即“no_of_files”)显示为UILabel,而我的代码就像..
NSMutableArray * aryy=[NSJSONSerialization JSONObjectWithData:responseObject  options:kNilOptions error:&error];
     jsonDisplay = [aryy valueForKey:@"sentdetails"];
     NSLog(@"%@",jsonDisplay);
     NSLog(@"\n\n\n%@",aryy);

     SentItemDetailViewController *viewController=[self.storyboard instantiateViewControllerWithIdentifier:@"SentItemDetailViewController"];

     viewController.numberofFiles = [[jsonDisplay objectAtIndex:0]valueForKey:@"no_of_files"];

但是“num_of_files”的值不能存储在UILable上,我不知道这是什么问题。

最佳答案

 NSNumber * num = [[jsonDisplay objectAtIndex:0]valueForKey:@"no_of_files"];
viewController.numberofFiles.text = [num stringValue];

关于ios - 在UILabel中显示json响应,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30730753/

10-10 11:34