How to format data for display in a text view

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.

Answers


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];

(All of this is first-week stuff -- if you don't know it you need to spend more time studying the fundamentals.)


You can create the HTML for the response and show it to webView for coloring


Need Your Help

Updating your Android app with another app

android google-play policy

Is it legal to update an Android app on the Play store with a totally different app under the same package name?

Write Kinect joint positions to txt on button click

c# kinect kinect-sdk

I would like to write joint positions to a txt file.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.