使用for...in...输出NSMutableArray内容和输入NSMutableDictionary

for...in...输出NSMutableDictionary(代码片段摘录如下)


NSString *path = [[NSBundle mainBundle] pathForResource:@"attention" ofType:@"plist"];
self.dataDic = [NSDictionary dictionaryWithContentsOfFile:path];
self.items = [NSMutableArray arrayWithCapacity:0];
for (id section in self.dataDic) {
    Item *item = [[Item alloc] init];
    item.title = [[self.dataDic objectForKey:section] valueForKey:@"title"];
    item.isChecked = NO;
    [_items addObject:item];
}	


for...in...输出NSMutableArray(代码片段摘录如下)


for (NSDictionary *item in _items) {
    NSLog(@"item.title = %@",[item valueForKey:@"title"]);
    NSLog(@"item.isChecked = %@",[item valueForKey:@"isChecked"]);
}


comments powered by Disqus