本文介绍了如何在目标c中的UITextView中显示JSON结果数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请考虑以下代码:
NSString *jsonreturn = [[NSString alloc] initWithContentsOfURL:[ NSURL URLWithString:url ]]; // Pulls the URL
NSLog(@"jsonreturn#########=%@",jsonreturn); // Look at the console and you can see what the restults are
NSData *jsonData = [jsonreturn dataUsingEncoding:NSUTF32BigEndianStringEncoding];
CJSONDeserializer *theDeserializer = [CJSONDeserializer deserializer];
theDeserializer.nullObject = NULL;
NSError *error = nil;
NSDictionary *dictt = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&error];
NSLog(@"###dict=%@", dictt);
if (dictt) {
rowsForQuestion = [[dictt objectForKey:@"faqdetails"] retain];// NSArray rowsForQuestion
}
[jsonreturn release];
//我已经在控制台中获取了这些数据,现在我想打印UITextView,但是我该怎么做
// I have got this data is in console NOW I WANT TO PRINT IT UITextView but HOW I can do it
faqdetails = (
{
faqAns = "Yes, Jack Kalis is the best crickter";
faqQues = "who is the best cricketer in present year?";
}
);
}
推荐答案
关于要显示在何处的问题,您的问题不是特别清楚,但是将文本拖放到UITextView中并不是一件容易的事.
Your question isn't particularly clear regarding what you want to show where, but dropped text into a UITextView couldn't be easier.
[yourTextView setText: [[rowsForQuestion objectAtIndex: 0] objectForKey: @"faqQues"]];
以上代码从rowsForQuestion
获取了第一个字典,并将@"faqQues"
的值放入UITextView.
The above code grabs the first dict from rowsForQuestion
, and puts its value for @"faqQues"
into a UITextView.
这篇关于如何在目标c中的UITextView中显示JSON结果数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!