Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

minor reformatting

  • Loading branch information...
commit e2dd0d497bb9c7306443275e3de8726600e0a597 1 parent ffa75ca
@Machx authored
Showing with 11 additions and 13 deletions.
  1. +11 −13 Source/NSArrayAdditions.m
View
24 Source/NSArrayAdditions.m
@@ -29,22 +29,22 @@ of this software and associated documentation files (the "Software"), to deal
@implementation NSArray (CWNSArrayAdditions)
-- (id) cw_firstObject
+-(id)cw_firstObject
{
return ( [self count] > 0 ) ? [self objectAtIndex:0] : nil;
}
-- (void) cw_each:(void (^)(id obj, NSUInteger index, BOOL *stop))block
+-(void)cw_each:(void (^)(id obj, NSUInteger index, BOOL *stop))block
{
[self enumerateObjectsUsingBlock:block];
}
-- (void) cw_eachConcurrentlyWithBlock:(void (^)(id obj, NSUInteger index, BOOL * stop))block
+-(void)cw_eachConcurrentlyWithBlock:(void (^)(id obj, NSUInteger index, BOOL * stop))block
{
[self enumerateObjectsWithOptions:NSEnumerationConcurrent usingBlock:block];
}
-- (id) cw_findWithBlock:(BOOL (^)(id obj))block
+-(id)cw_findWithBlock:(BOOL (^)(id obj))block
{
__block id foundObject = nil;
[self cw_eachConcurrentlyWithBlock:^(id object, NSUInteger index, BOOL *stop) {
@@ -56,14 +56,14 @@ - (id) cw_findWithBlock:(BOOL (^)(id obj))block
return foundObject;
}
-- (BOOL) cw_isObjectInArrayWithBlock:(BOOL (^)(id obj))block
+-(BOOL)cw_isObjectInArrayWithBlock:(BOOL (^)(id obj))block
{
return ( [self cw_findWithBlock:block] ) ? YES : NO;
}
-- (NSArray *) cw_findAllWithBlock:(BOOL (^)(id obj))block
+-(NSArray *)cw_findAllWithBlock:(BOOL (^)(id obj))block
{
- NSMutableArray * results = [[NSMutableArray alloc] init];
+ NSMutableArray * results = [NSMutableArray array];
[self cw_each:^(id obj, NSUInteger index, BOOL *stop) {
if (block(obj)) {
[results addObject:obj];
@@ -74,7 +74,7 @@ - (NSArray *) cw_findAllWithBlock:(BOOL (^)(id obj))block
#if Z_HOST_OS_IS_MAC_OS_X
-- (NSHashTable *) cw_findAllIntoWeakRefsWithBlock:(BOOL (^)(id))block
+-(NSHashTable *)cw_findAllIntoWeakRefsWithBlock:(BOOL (^)(id))block
{
NSHashTable * results = [NSHashTable hashTableWithWeakObjects];
[self cw_each:^(id obj, NSUInteger index, BOOL *stop) {
@@ -87,9 +87,9 @@ - (NSHashTable *) cw_findAllIntoWeakRefsWithBlock:(BOOL (^)(id))block
#endif
-- (NSArray *) cw_mapArray:(id (^)(id obj))block
+-(NSArray *)cw_mapArray:(id (^)(id obj))block
{
- NSMutableArray * cwArray = [[NSMutableArray alloc] init];
+ NSMutableArray * cwArray = [NSMutableArray array];
[self cw_each:^(id obj, NSUInteger index, BOOL *stop) {
id rObj = block(obj);
if (rObj) {
@@ -99,16 +99,14 @@ - (NSArray *) cw_mapArray:(id (^)(id obj))block
return cwArray;
}
-- (NSArray *) cw_arrayOfObjectsPassingTest:(BOOL (^)(id obj))block
+-(NSArray *)cw_arrayOfObjectsPassingTest:(BOOL (^)(id obj))block
{
NSMutableArray *array = [NSMutableArray array];
-
[self cw_each:^(id object, NSUInteger index, BOOL *stop) {
if (block(object)) {
[array addObject:object];
}
}];
-
return array;
}
Please sign in to comment.
Something went wrong with that request. Please try again.