码迷,mamicode.com
首页 > 编程语言 > 详细

oc block 遍历数组及字典

时间:2016-07-13 10:27:04      阅读:220      评论:0      收藏:0      [点我收藏+]

标签:

原遍历数组
NSArray * lines = ...
for (NSString * line in lines) {
// ...
}
for (int i = 0; i < lines.count; ++i) {
NSString * s = [lines objectAtIndex:i];
...
}
原遍历字典
NSDictionary * dict = …
NSArray * keys = [dict allKeys];
for (NSString * key in keys) {
NSString * value = [dict objectForKey:key];

}
block遍历
[lines enumerateObjectsUsingBlock:^(NSString * obj, NSUInteger idx, BOOL *stop) {

}];

[_urlArguments enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {

}];

oc block 遍历数组及字典

标签:

原文地址:http://www.cnblogs.com/Xujg/p/5665866.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!