在我的代码中,我将数组设置在NSMutableDictionary
内作为
if (array.count > 0) {
[self.filters setValue:array forKey:[self getKey:[[NSNumber numberWithInt:indexPath.section] intValue]]];
}
其中array
是
NSMutableArray *array = [[NSMutableArray alloc] init];
当接收代码收到它时,我试图将数组中的值加入
if ([item objectForKey:@"category_filter"] != nil) {
NSArray *array = [NSArray arrayWithObjects:[item objectForKey:@"category_filter"], nil];
NSString *categories = [array componentsJoinedByString:@","];
NSLog(@"value:%@", categories);
}
其中item
为(NSMutableDictionary *)item
当我看到日志时,我看到
2014-06-24 17:43:12.520 yelp[69744:70b] value:(
"Bagels (bagels)",
"Bakeries (bakeries)"
)
所以他们还没有加入。我在这里做错了什么?
答案 0 :(得分:1)
我必须做出改变
NSArray *array = [NSArray arrayWithArray:[item objectForKey:@"category_filter"]];
而不是
NSArray *array = [NSArray arrayWithObjects:[item objectForKey:@"category_filter"]];