首页 > 其他 > 详细

Block 代替for循环

时间:2014-06-12 15:18:15      阅读:402      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
  NSDictionary *aDictionary = [[NSDictionary alloc]initWithObjectsAndKeys:@"tom",@"1",@"alex",@"2",@"josen",@"3", nil];
        [aDictionary enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL *stop) {
            NSLog(@"value for key %@ is %@", key, value);
            if ([@"2" isEqualToString:key]) {
                *stop = YES; }
        }];
        
        NSArray *aArray = [[NSArray alloc]initWithObjects:@"1",@"2",@"3",@"4",@"5", nil];
        [aArray enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop){
             NSLog(@"----%@ ---%ld",[aArray objectAtIndex:index],index);
            if (index == 2) {
                *stop = YES;

            }
        }];
bubuko.com,布布扣

 

Block 代替for循环,布布扣,bubuko.com

Block 代替for循环

原文:http://www.cnblogs.com/joesen/p/3782025.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!