I have used web service and get the response as the JSON. I want to extract the details from the array.
Here my sample code,
NSString *urlDataString = [[NSString alloc] initWithData:receiveData encoding:NSUTF8StringEncoding];
SBJSON *parser = [[SBJSON alloc] init];
NSError *error = nil;
self.customArray = [parser objectWithString:urlDataString error:&error];
for (NSDictionary *feedItem in customArray)
{
NSString *listDeals = [feedItem objectForKey:@"ListOfDeals"];
[tempArray addObject:listDeals];
}
If i have used the above code all the strings are stored into the temp array and the array value 1. But i want to store the data are to be separate index.So that i have to get the details using the index position.
if i am using like this,
for (NSDictionary *feedItem in self.dollarArray)
{
NSString *listDeals = [[feedItem objectForKey:@"ListOfDeals"] valueForKey:@"Description"];
[tempArray addObject:listDeals];
}
I get all the description values from tempArray, but i want to get all the strings from the array.
Actually i am expecting the temp array count 3 and want to get values like
NSLog(@"%@",[tempArray ObjectAtIndex:0]);
{
BusId = 14;
Description = "Sample data"
Id = 60;
StartTime = "7/28/2011 8:30:00 PM";
},
Here my sample response,
(
ListOfDetails = (
{
BusId = 14;
Description = "Sample data"
Id = 60;
StartTime = "7/28/2011 8:30:00 PM";
},
{
BusId = 16;
Description = "Test data"
Id = 62;
StartTime = "7/29/2011 8:30:00 PM";
},
{
BusId = 15;
Description = "Test"
Id = 61;
StartTime = "7/27/2011 8:30:00 PM";
},
)
So how can i do that? Please guide me.
Thanks!