Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: lavoy/ALToolkit
base: 74c520fe41
...
head fork: lavoy/ALToolkit
compare: bcd870f0bc
  • 2 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
View
39 ALToolkit.xcodeproj/project.xcworkspace/xcshareddata/ALToolkit.xccheckout
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>IDESourceControlProjectIdentifier</key>
+ <string>AE5C8D71-6645-4414-AABE-6C55948D72E1</string>
+ <key>IDESourceControlProjectName</key>
+ <string>ALToolkit</string>
+ <key>IDESourceControlProjectOriginsDictionary</key>
+ <dict>
+ <key>89923B14-15BE-448B-9220-82B030AD5901</key>
+ <string>https://github.com/lavoy/ALToolkit.git</string>
+ </dict>
+ <key>IDESourceControlProjectPath</key>
+ <string>ALToolkit.xcodeproj/project.xcworkspace</string>
+ <key>IDESourceControlProjectRelativeInstallPathDictionary</key>
+ <dict>
+ <key>89923B14-15BE-448B-9220-82B030AD5901</key>
+ <string>../..</string>
+ </dict>
+ <key>IDESourceControlProjectURL</key>
+ <string>https://github.com/lavoy/ALToolkit.git</string>
+ <key>IDESourceControlProjectVersion</key>
+ <integer>110</integer>
+ <key>IDESourceControlProjectWCCIdentifier</key>
+ <string>89923B14-15BE-448B-9220-82B030AD5901</string>
+ <key>IDESourceControlProjectWCConfigurations</key>
+ <array>
+ <dict>
+ <key>IDESourceControlRepositoryExtensionIdentifierKey</key>
+ <string>public.vcs.git</string>
+ <key>IDESourceControlWCCIdentifierKey</key>
+ <string>89923B14-15BE-448B-9220-82B030AD5901</string>
+ <key>IDESourceControlWCCName</key>
+ <string>ALToolkit</string>
+ </dict>
+ </array>
+</dict>
+</plist>
View
1  ALToolkit/ALToolkit/NSArray+ALToolkitAdditions.h
@@ -12,5 +12,6 @@
- (id)safeObjectAtIndex:(NSUInteger)index;
- (NSArray *)al_map:(id (^)(id object))mapBlock;
- (NSArray *)al_filter:(BOOL (^)(id object))filterBlock;
+- (id)al_find:(BOOL (^)(id object))findBlock;
@end
View
11 ALToolkit/ALToolkit/NSArray+ALToolkitAdditions.m
@@ -49,4 +49,15 @@ - (NSArray *)al_filter:(BOOL (^)(id object))filterBlock {
}
+- (id)al_find:(BOOL (^)(id object))findBlock {
+ for (id object in self) {
+ if (findBlock(object)) {
+ return object;
+ }
+ }
+
+ return nil;
+}
+
+
@end
View
19 ALToolkitTests/NSArrayTests.m
@@ -69,6 +69,25 @@ - (void)testFilter
STAssertEqualObjects(filteredArray[4], @(4), nil);
}
+- (void)testFind
+{
+ NSNumber *foundObject0 = [self.array al_find:^BOOL(NSNumber *num) {
+ return [num integerValue] < 5;
+ }];
+
+ NSNumber *foundObject6 = [self.array al_find:^BOOL(NSNumber *num) {
+ return [num integerValue] > 5;
+ }];
+
+ NSNumber *foundObject20 = [self.array al_find:^BOOL(NSNumber *num) {
+ return [num integerValue] > 19;
+ }];
+
+ STAssertEqualObjects(foundObject0, @(0), nil);
+ STAssertEqualObjects(foundObject6, @(6), nil);
+ STAssertNil(foundObject20, nil);
+}
+
- (void)testSafeObject
{
STAssertEqualObjects([self.array safeObjectAtIndex:0], @(0), nil);

No commit comments for this range

Something went wrong with that request. Please try again.