0

I have a button that shows some part of the URL on a text view, but I would like for this information to be shown in a specific format.

- (IBAction)Accesos:(id)sender {
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"URL"]];
NSError* error;
NSDictionary* json = [NSJSONSerialization
                      JSONObjectWithData:data
                      options:kNilOptions
                      error:&error];
NSArray* Response_array = [json objectForKey:@"avenidas"]; 
for (int i=0; i < Response_array.count; i++){ 
NSDictionary* item = [Response_array objectAtIndex:i]; 
NSString* name = [item objectForKey:@"name"]; 
NSString* state = [item objectForKey:@"state"]; 
NSString* space = @"\n";
NSString* formattedString = [NSString stringWithFormat:@"%@%@: %@",space, name, state];  
txt_webservice_response.text = formattedString; } 
}

The information is shown the same as in the URL I would like to display the information like name: state and then the state to be in color depending the type if it is possible.

4

2 回答 2

0

您可以为响应创建 HTML 并将其显示给 webView 以进行着色

于 2013-05-02T23:26:00.143 回答
0
NSArray* items = [someDictionary objectForKey:@"avenidas"];
NSDictionary* item = [items objectAtIndex:someIndex];
NSString* name = [item objectForKey:@"name"];
NSString* state = [item objectForKey:@"state"];
NSString* formattedString = [NSString stringWithFormat:@"%@:%@", name, state];

(所有这些都是第一周的东西——如果你不知道,你需要花更多的时间学习基础知识。)

于 2013-05-03T00:49:06.137 回答