ios - How to format data for display in a text view -
i have button shows part of url on text view, information shown in 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"]; (int i=0; < 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 shown same in url display information name: state , state in color depending type if possible.
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 first-week stuff -- if don't know need spend more time studying fundamentals.)
Comments
Post a Comment