ios - 在UILabel中显示json响应

标签 ios json uilabel

我的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/

相关文章:

ios - 在 iOS 上原生渲染 UILabel/UITextfield 中的 LaTeX 代码

ios - 代码签名错误 : Application failed codesign verification

javascript - jQuery 数组处理不当 : length= 0 bug?

java - 在 Java 中解析 GitHub API 响应

iphone - xml文件的CDATA中的下标和上标。使用UILabel显示已解析的XML内容

ios - 如何找到 UILabel 的实际行数?

ios - 在 Xcode 中运行 2 个自定义 shell 脚本中的 1 个卡住了 2 分钟

ios - 在 iOS 中添加 Lottie 动画

javascript - 使用 ng-repeat (AngularJS) 迭代 JSON

iOS 旋转标签如果太长