Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added block based enumerator support.

  • Loading branch information...
commit 487ad7460c948aa13f4d93f262225710fff48a5f 1 parent 619f1f5
@omnivector omnivector authored
View
6 BlockPlayground/BlockPlayground.xcodeproj/project.pbxproj
@@ -8,6 +8,7 @@
/* Begin PBXBuildFile section */
6A259F9B13D273DB0034CA1D /* NSDate-BKAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 6A259F9A13D273DB0034CA1D /* NSDate-BKAdditions.m */; };
+ 6A259FBE13D28BC20034CA1D /* NSEnumerator-BKAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 6A259FBD13D28BC20034CA1D /* NSEnumerator-BKAdditions.m */; };
F13EAA7F13D25084008C9BD2 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F13EAA7E13D25084008C9BD2 /* UIKit.framework */; };
F13EAA8113D25084008C9BD2 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F13EAA8013D25084008C9BD2 /* Foundation.framework */; };
F13EAA8313D25084008C9BD2 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F13EAA8213D25084008C9BD2 /* CoreGraphics.framework */; };
@@ -37,6 +38,8 @@
/* Begin PBXFileReference section */
6A259F9913D273DB0034CA1D /* NSDate-BKAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDate-BKAdditions.h"; sourceTree = "<group>"; };
6A259F9A13D273DB0034CA1D /* NSDate-BKAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDate-BKAdditions.m"; sourceTree = "<group>"; };
+ 6A259FBC13D28BC20034CA1D /* NSEnumerator-BKAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSEnumerator-BKAdditions.h"; sourceTree = "<group>"; };
+ 6A259FBD13D28BC20034CA1D /* NSEnumerator-BKAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSEnumerator-BKAdditions.m"; sourceTree = "<group>"; };
F13EAA7A13D25084008C9BD2 /* BlockPlayground.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BlockPlayground.app; sourceTree = BUILT_PRODUCTS_DIR; };
F13EAA7E13D25084008C9BD2 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
F13EAA8013D25084008C9BD2 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
@@ -188,6 +191,8 @@
F13EAAB713D251D2008C9BD2 /* UIImage-BKAdditions.m */,
F13EAAB813D251D2008C9BD2 /* UIView-BKAdditions.h */,
F13EAAB913D251D2008C9BD2 /* UIView-BKAdditions.m */,
+ 6A259FBC13D28BC20034CA1D /* NSEnumerator-BKAdditions.h */,
+ 6A259FBD13D28BC20034CA1D /* NSEnumerator-BKAdditions.m */,
);
name = BlockKit;
path = ../../Source;
@@ -274,6 +279,7 @@
F13EAACB13D25555008C9BD2 /* NSURLConnection-BKAdditions.m in Sources */,
F13EAACE13D25DD1008C9BD2 /* NSString-BKAdditions.m in Sources */,
6A259F9B13D273DB0034CA1D /* NSDate-BKAdditions.m in Sources */,
+ 6A259FBE13D28BC20034CA1D /* NSEnumerator-BKAdditions.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
2  Source/BKTypes.h
@@ -16,4 +16,4 @@ typedef void (^BKButtonIndexBlock)(NSInteger buttonIndex);
typedef void (^BKStringBlock)(NSString *string);
typedef void (^BKUniCharBlock)(unichar character);
typedef void (^BKConnectionCompletionBlock)(NSData *responseData, NSURLResponse *urlResponse, NSError *error);
-typedef void (^BKDateBlock)(NSDate *date);
+typedef void (^BKDateBlock)(NSDate *date);
View
15 Source/NSEnumerator-BKAdditions.h
@@ -0,0 +1,15 @@
+//
+// NSEnumerator-BKAdditions.h
+// BlockKit
+//
+// Created by Tristan O'Tierney on 7/16/11.
+//
+
+#import "BKTypes.h"
+
+
+@interface NSEnumerator (BKAdditions)
+
+- (void)enumerateObjectsUsingBlock:(void (^)(id obj, BOOL *stop))block;
+
+@end
View
27 Source/NSEnumerator-BKAdditions.m
@@ -0,0 +1,27 @@
+//
+// NSEnumerator-BKAdditions.m
+// BlockKit
+//
+// Created by Tristan O'Tierney on 7/16/11.
+//
+
+#import "NSEnumerator-BKAdditions.h"
+
+
+@implementation NSEnumerator (BKAdditions)
+
+- (void)enumerateObjectsUsingBlock:(void (^)(id obj, BOOL *stop))block;
+{
+ if (!block) {
+ return;
+ }
+
+ id object = nil;
+ BOOL stop = NO;
+
+ while (!stop && (object = [self nextObject])) {
+ block(object, &stop);
+ }
+}
+
+@end
Please sign in to comment.
Something went wrong with that request. Please try again.