
Untitled
By: a guest on
Jun 21st, 2012 | syntax:
None | size: 1.85 KB | hits: 11 | expires: Never
how to check condition for parsed elements in iphone
NSArray *feed3 = (NSArray *)[feed valueForKey:@"type"];
NSLog(@" %@",feed3);
if(type==staus){
//do some thing
}
* the top level object is an array
* every element in the array is an object/dictionary representing news
* this object/dictionary contains the following keys:
* application (object/dictionary with two keys: id, name)
* id (number)
* name (string)
* created_time (string)
* from (object/dictionary with two keys: id, name)
* id (number)
* name (string)
* icon (string)
* id (string)
* likes (object/dictionary with two keys: count, data)
* count (number)
* data (array)
* every element in the array is an object/dictionary
* this object/dictionary has two keys (id, name)
* id (number)
* name (string)
* link (string)
* name (string)
* picture (string)
* properties (array of objects/dictionaries)
* type (string)
* updated_time (string)
for (NSDictionary *news in feed3) {
NSString *type = [news objectForKey:@"type"];
if ([type isEqualToString:@"status"]) {
…
}
else if ([type isEqualToString:@"photo"]) {
…
}
else if ([type isEqualToString:@"link"]) {
…
}
else if ([type isEqualToString:@"video"]) {
…
}
}
for(int index = 0 ; index < [feed3 count] ; index++)
{
NSString* tempString = [feed3 objectAtIndex:index];
if([tempString isEqualToString:@"status"])
{
//Get value for status from value array
}
else if([tempString isEqualToString:@"photo"])
{
//Get value for photo from value array
}
else if([tempString isEqualToString:@"link"])
{
//Get value for link from value array
}
else if([tempString isEqualToString:@"video"])
{
//Get value for video from value array
}
}