Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // NSArray+DSLFirstItems.m
- //
- // Created by Pete Callaway on 15/10/2010.
- // Copyright 2010 Dative Studios. All rights reserved.
- // Modified by Abizer Nasir
- //
- #import "NSArray+DSLFirstItems.h"
- @implementation NSArray (DSLFirstItems)
- - (void)dsl_enumerateUpTo:(NSUInteger)numberOfItemsToEnumerate inDirection:(DSLEnumerationOption)direction usingBlock:(DSLFirstItemWorkBlock)block {
- NSInteger count = 0;
- BOOL stop = NO;
- id <NSFastEnumeration> iterable;
- if (direction == DSLEnumerationForward) {
- iterable = self;
- } else {
- iterable = [self reverseObjectEnumerator];
- }
- for (id object in iterable) {
- block(object, count, &stop);
- if (stop) return;
- count++;
- if (count >= numberOfItemsToEnumerate) return;
- }
- }
- @end
Add Comment
Please, Sign In to add comment