1

I m a noob what i want is to convert a NSDictionary object to NSInteger.i m parsing json objects and storing it in an NSMutableArray,which is then stored in NSDictionary object called boy.could you guys help me out.below is the code.

        NSURLRequest *request = [NSURLRequest requestWithURL:jsonurl cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
connection1=[[[NSURLConnection alloc] initWithRequest:request delegate:self] autorelease];


NSLog(@"jsonurl:%@",jsonurl);
self.jsonData=[NSData dataWithContentsOfURL:jsonurl];

NSDictionary *items=[NSJSONSerialization JSONObjectWithData:self.jsonData options:NSJSONReadingMutableLeaves error:nil];
NSLog(@"blah:%@",jsonArray);
items1 = [items objectForKey:@"ThingsTodo"];

story = [[NSMutableArray array]retain];
media1 = [[NSMutableArray array]retain];

url=[[NSMutableArray array]retain];
media2=[[NSMutableArray array]retain];
descriptiondesc=[[NSMutableArray array]retain];
for (NSDictionary *item in items1)
{
    [self.story addObject:[item objectForKey:@"Name"]];
    [self.media1 addObject:[item objectForKey:@"Status"]];
    [self.media2 addObject:[item objectForKey:@"Image"]];

}
    NSDictionary *boy=[self.media1 objectAtIndex:indexPath.row];
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
stephensam
  • 91
  • 3
  • 12

2 Answers2

10

Put your nsdictionary value into nsstring and then take an NSInteger and do like :

NSInteger n = [strVal intValue];
Yama
  • 2,649
  • 3
  • 31
  • 63
2

To be more specific "intValue" gives "int" while "integerValue" returns "NSInteger" so

NSInteger n = [strVal integerValue];
hariszaman
  • 8,202
  • 2
  • 40
  • 59