我想要的是将NSDictionary对象转换为NSInteger.im解析json对象并将其存储在NSMutableArray中,然后将其存储在名为boy的NSDictionary对象中。你们可以帮助我。下面是代码
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];
答案 0 :(得分:7)
将nsdictionary
值放入nsstring
,然后选择NSInteger
并执行以下操作:
NSInteger n = [strVal intValue];
答案 1 :(得分:1)
更具体的说法" intValue"给出" int"而" integerValue"返回" NSInteger"所以
NSInteger n = [strVal integerValue];