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

{app.params.name}} {app.params.name}} {app.params.name}}

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"]);
}



版权声明

davidzhang 创作并维护的 Gowhich 博客采用 创作共用保留署名-非商业-禁止演绎4.0国际许可证。

本文首发于 Gowhich 博客( https://www.gowhich.com ),版权所有,侵权必究。

本文永久链接: https://www.gowhich.com/blog/134

comments powered by Disqus