vendredi 2 janvier 2015

create loop for array to get string from json String?

i need to display a Table View containing information from web service response i do no where iam doing wrong here my sample code



NSData *data = [soapResultsString dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];

NSArray *array = [json allValues];

for (int i=0; i<array.count; i++)
{
recordResults =NO;
appDelegate.rateString =[[[json valueForKey:@"plan_history"]valueForKey:@"rate"]objectAtIndex:i];
appDelegate.descriptionString=[[[json valueForKey:@"plan_history"]valueForKey:@"description"]objectAtIndex:i];
appDelegate.validityString=[[[json valueForKey:@"plan_history"]valueForKey:@"validity"]objectAtIndex:i];
appDelegate.plantypeString=[[[json valueForKey:@"plan_history"]valueForKey:@"plantype"]objectAtIndex:i];

}


i need to parse 4 values from plan_history like "rate","description","validity","plan type" when i run my app i getting only one set of value in Table view . i.e my json string contains more than 20 records containing rate,description,validity and plan type

can u show me how to loop my json value and display all my records in Table View




Aucun commentaire:

Enregistrer un commentaire