Skip to content
Browse files

re-released v0.1.2. moved ConciseKitSpecs/src to /src.

  • Loading branch information...
1 parent 5fbf788 commit 4a70ea47856c3b0698f8330f19a557295068940e @petejkim committed
View
67 ConciseKitSpecs/ConciseKitSpecs.xcodeproj/project.pbxproj
@@ -20,14 +20,14 @@
E91C43C612985E7D001522E5 /* OCMock.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E92CB4F01296DF2B00BF1922 /* OCMock.framework */; };
E925015812D92E250018D373 /* NSDictionaryConciseKitSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = E925015712D92E250018D373 /* NSDictionaryConciseKitSpec.m */; };
E953689A1521C7BA00AA3B81 /* README.md in Resources */ = {isa = PBXBuildFile; fileRef = E95368991521C7BA00AA3B81 /* README.md */; };
+ E95368B01521CA5A00AA3B81 /* ConciseKit.m in Sources */ = {isa = PBXBuildFile; fileRef = E95368A91521CA5A00AA3B81 /* ConciseKit.m */; };
+ E95368B11521CA5A00AA3B81 /* NSArray+ConciseKit.m in Sources */ = {isa = PBXBuildFile; fileRef = E95368AB1521CA5A00AA3B81 /* NSArray+ConciseKit.m */; };
+ E95368B21521CA5A00AA3B81 /* NSDictionary+ConciseKit.m in Sources */ = {isa = PBXBuildFile; fileRef = E95368AD1521CA5A00AA3B81 /* NSDictionary+ConciseKit.m */; };
+ E95368B31521CA5A00AA3B81 /* NSString+ConciseKit.m in Sources */ = {isa = PBXBuildFile; fileRef = E95368AF1521CA5A00AA3B81 /* NSString+ConciseKit.m */; };
E965CE8C12A17FC400416CDF /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = E965CE8A12A17FC400416CDF /* LICENSE */; };
E965CE9412A1805800416CDF /* NSArrayConciseKitSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = E965CE9312A1805800416CDF /* NSArrayConciseKitSpec.m */; };
E965CFC212A18A5000416CDF /* ConciseKitSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = E965CFC112A18A5000416CDF /* ConciseKitSpec.m */; };
E9692C2612B4B4FF00520396 /* NSStringConciseKitSpec.m in Sources */ = {isa = PBXBuildFile; fileRef = E9692C2512B4B4FF00520396 /* NSStringConciseKitSpec.m */; };
- E9B778E414BA583600D8DC76 /* ConciseKit.m in Sources */ = {isa = PBXBuildFile; fileRef = E9B778DD14BA583600D8DC76 /* ConciseKit.m */; };
- E9B778E514BA583600D8DC76 /* NSArray+ConciseKit.m in Sources */ = {isa = PBXBuildFile; fileRef = E9B778DF14BA583600D8DC76 /* NSArray+ConciseKit.m */; };
- E9B778E614BA583600D8DC76 /* NSDictionary+ConciseKit.m in Sources */ = {isa = PBXBuildFile; fileRef = E9B778E114BA583600D8DC76 /* NSDictionary+ConciseKit.m */; };
- E9B778E714BA583600D8DC76 /* NSString+ConciseKit.m in Sources */ = {isa = PBXBuildFile; fileRef = E9B778E314BA583600D8DC76 /* NSString+ConciseKit.m */; };
E9E4CF061298753B0093F83D /* Cedar.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = E92CB4EC1296DF2B00BF1922 /* Cedar.framework */; };
E9E4CF071298753B0093F83D /* OCHamcrest.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = E92CB4EE1296DF2B00BF1922 /* OCHamcrest.framework */; };
E9E4CF081298753B0093F83D /* OCMock.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = E92CB4F01296DF2B00BF1922 /* OCMock.framework */; };
@@ -71,21 +71,21 @@
E92CB57E1296E1D800BF1922 /* CedarAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CedarAdditions.h; sourceTree = "<group>"; };
E92CB57F1296E1D800BF1922 /* CedarAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CedarAdditions.m; sourceTree = "<group>"; };
E95368991521C7BA00AA3B81 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = README.md; path = ../README.md; sourceTree = "<group>"; };
+ E95368A51521CA5A00AA3B81 /* CKAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CKAdditions.h; sourceTree = "<group>"; };
+ E95368A61521CA5A00AA3B81 /* CKMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CKMacros.h; sourceTree = "<group>"; };
+ E95368A71521CA5A00AA3B81 /* CKSingleton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CKSingleton.h; sourceTree = "<group>"; };
+ E95368A81521CA5A00AA3B81 /* ConciseKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConciseKit.h; sourceTree = "<group>"; };
+ E95368A91521CA5A00AA3B81 /* ConciseKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ConciseKit.m; sourceTree = "<group>"; };
+ E95368AA1521CA5A00AA3B81 /* NSArray+ConciseKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+ConciseKit.h"; sourceTree = "<group>"; };
+ E95368AB1521CA5A00AA3B81 /* NSArray+ConciseKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+ConciseKit.m"; sourceTree = "<group>"; };
+ E95368AC1521CA5A00AA3B81 /* NSDictionary+ConciseKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+ConciseKit.h"; sourceTree = "<group>"; };
+ E95368AD1521CA5A00AA3B81 /* NSDictionary+ConciseKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+ConciseKit.m"; sourceTree = "<group>"; };
+ E95368AE1521CA5A00AA3B81 /* NSString+ConciseKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+ConciseKit.h"; sourceTree = "<group>"; };
+ E95368AF1521CA5A00AA3B81 /* NSString+ConciseKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+ConciseKit.m"; sourceTree = "<group>"; };
E965CE8A12A17FC400416CDF /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
E965CE9312A1805800416CDF /* NSArrayConciseKitSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSArrayConciseKitSpec.m; sourceTree = "<group>"; };
E965CFC112A18A5000416CDF /* ConciseKitSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ConciseKitSpec.m; sourceTree = "<group>"; };
E9692C2512B4B4FF00520396 /* NSStringConciseKitSpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSStringConciseKitSpec.m; sourceTree = "<group>"; };
- E9B778D914BA583600D8DC76 /* CKAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CKAdditions.h; sourceTree = "<group>"; };
- E9B778DA14BA583600D8DC76 /* CKMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CKMacros.h; sourceTree = "<group>"; };
- E9B778DB14BA583600D8DC76 /* CKSingleton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CKSingleton.h; sourceTree = "<group>"; };
- E9B778DC14BA583600D8DC76 /* ConciseKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConciseKit.h; sourceTree = "<group>"; };
- E9B778DD14BA583600D8DC76 /* ConciseKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ConciseKit.m; sourceTree = "<group>"; };
- E9B778DE14BA583600D8DC76 /* NSArray+ConciseKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+ConciseKit.h"; sourceTree = "<group>"; };
- E9B778DF14BA583600D8DC76 /* NSArray+ConciseKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+ConciseKit.m"; sourceTree = "<group>"; };
- E9B778E014BA583600D8DC76 /* NSDictionary+ConciseKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+ConciseKit.h"; sourceTree = "<group>"; };
- E9B778E114BA583600D8DC76 /* NSDictionary+ConciseKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+ConciseKit.m"; sourceTree = "<group>"; };
- E9B778E214BA583600D8DC76 /* NSString+ConciseKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+ConciseKit.h"; sourceTree = "<group>"; };
- E9B778E314BA583600D8DC76 /* NSString+ConciseKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+ConciseKit.m"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -116,7 +116,7 @@
children = (
E95368991521C7BA00AA3B81 /* README.md */,
E965CE8A12A17FC400416CDF /* LICENSE */,
- E9B778D814BA583500D8DC76 /* src */,
+ E95368A41521CA5A00AA3B81 /* src */,
E92CB3401296DC6100BF1922 /* Spec */,
29B97323FDCFA39411CA2CEA /* Frameworks */,
19C28FACFE9D520D11CA2CBB /* Products */,
@@ -177,22 +177,23 @@
path = Support;
sourceTree = "<group>";
};
- E9B778D814BA583500D8DC76 /* src */ = {
+ E95368A41521CA5A00AA3B81 /* src */ = {
isa = PBXGroup;
children = (
- E9B778D914BA583600D8DC76 /* CKAdditions.h */,
- E9B778DA14BA583600D8DC76 /* CKMacros.h */,
- E9B778DB14BA583600D8DC76 /* CKSingleton.h */,
- E9B778DC14BA583600D8DC76 /* ConciseKit.h */,
- E9B778DD14BA583600D8DC76 /* ConciseKit.m */,
- E9B778DE14BA583600D8DC76 /* NSArray+ConciseKit.h */,
- E9B778DF14BA583600D8DC76 /* NSArray+ConciseKit.m */,
- E9B778E014BA583600D8DC76 /* NSDictionary+ConciseKit.h */,
- E9B778E114BA583600D8DC76 /* NSDictionary+ConciseKit.m */,
- E9B778E214BA583600D8DC76 /* NSString+ConciseKit.h */,
- E9B778E314BA583600D8DC76 /* NSString+ConciseKit.m */,
+ E95368A51521CA5A00AA3B81 /* CKAdditions.h */,
+ E95368A61521CA5A00AA3B81 /* CKMacros.h */,
+ E95368A71521CA5A00AA3B81 /* CKSingleton.h */,
+ E95368A81521CA5A00AA3B81 /* ConciseKit.h */,
+ E95368A91521CA5A00AA3B81 /* ConciseKit.m */,
+ E95368AA1521CA5A00AA3B81 /* NSArray+ConciseKit.h */,
+ E95368AB1521CA5A00AA3B81 /* NSArray+ConciseKit.m */,
+ E95368AC1521CA5A00AA3B81 /* NSDictionary+ConciseKit.h */,
+ E95368AD1521CA5A00AA3B81 /* NSDictionary+ConciseKit.m */,
+ E95368AE1521CA5A00AA3B81 /* NSString+ConciseKit.h */,
+ E95368AF1521CA5A00AA3B81 /* NSString+ConciseKit.m */,
);
- path = src;
+ name = src;
+ path = ../src;
sourceTree = "<group>";
};
/* End PBXGroup section */
@@ -270,11 +271,11 @@
E90DADE612A6A07A000A36AE /* CKMocks.m in Sources */,
E9692C2612B4B4FF00520396 /* NSStringConciseKitSpec.m in Sources */,
E925015812D92E250018D373 /* NSDictionaryConciseKitSpec.m in Sources */,
- E9B778E414BA583600D8DC76 /* ConciseKit.m in Sources */,
- E9B778E514BA583600D8DC76 /* NSArray+ConciseKit.m in Sources */,
- E9B778E614BA583600D8DC76 /* NSDictionary+ConciseKit.m in Sources */,
- E9B778E714BA583600D8DC76 /* NSString+ConciseKit.m in Sources */,
CB6C70DD14E21B3A0016D5D7 /* NSSetConciseKitSpec.m in Sources */,
+ E95368B01521CA5A00AA3B81 /* ConciseKit.m in Sources */,
+ E95368B11521CA5A00AA3B81 /* NSArray+ConciseKit.m in Sources */,
+ E95368B21521CA5A00AA3B81 /* NSDictionary+ConciseKit.m in Sources */,
+ E95368B31521CA5A00AA3B81 /* NSString+ConciseKit.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
3 ConciseKitSpecs/src/CKAdditions.h
@@ -1,3 +0,0 @@
-#import "NSArray+ConciseKit.h"
-#import "NSString+ConciseKit.h"
-#import "NSDictionary+ConciseKit.h"
View
49 ConciseKitSpecs/src/CKMacros.h
@@ -1,49 +0,0 @@
-#ifndef __has_feature
- #define __has_feature(x) 0
-#endif
-#if __has_feature(objc_arc)
- #define IF_ARC(with, without) with
-#else
- #define IF_ARC(with, without) without
-#endif
-
-#define $new(Klass) IF_ARC([[Klass alloc] init], [[[Klass alloc] init] autorelease])
-#define $eql(a,b) [(a) isEqual:(b)]
-
-#define $arr(...) [NSArray arrayWithObjects:__VA_ARGS__, nil]
-#define $marr(...) [NSMutableArray arrayWithObjects:__VA_ARGS__, nil]
-#define $marrnew [NSMutableArray array]
-#define $set(...) [NSSet setWithObjects:__VA_ARGS__, nil]
-#define $mset(...) [NSMutableSet setWithObjects:__VA_ARGS__, nil]
-#define $msetnew [NSMutableSet set]
-#define $dict(...) [NSDictionary dictionaryWithObjectsAndKeys:__VA_ARGS__, nil]
-#define $mdict(...) [NSMutableDictionary dictionaryWithObjectsAndKeys:__VA_ARGS__, nil]
-#define $mdictnew [NSMutableDictionary dictionary]
-#define $str(...) [NSString stringWithFormat:__VA_ARGS__]
-#define $mstr(...) [NSMutableString stringWithFormat:__VA_ARGS__]
-#define $mstrnew [NSMutableString string]
-
-#define $bool(val) [NSNumber numberWithBool:(val)]
-#define $char(val) [NSNumber numberWithChar:(val)]
-#define $double(val) [NSNumber numberWithDouble:(val)]
-#define $float(val) [NSNumber numberWithFloat:(val)]
-#define $int(val) [NSNumber numberWithInt:(val)]
-#define $integer(val) [NSNumber numberWithInteger:(val)]
-#define $long(val) [NSNumber numberWithLong:(val)]
-#define $longlong(val) [NSNumber numberWithLongLong:(val)]
-#define $short(val) [NSNumber numberWithShort:(val)]
-#define $uchar(val) [NSNumber numberWithUnsignedChar:(val)]
-#define $uint(val) [NSNumber numberWithUnsignedInt:(val)]
-#define $uinteger(val) [NSNumber numberWithUnsignedInteger:(val)]
-#define $ulong(val) [NSNumber numberWithUnsignedLong:(val)]
-#define $ulonglong(val) [NSNumber numberWithUnsignedLongLong:(val)]
-#define $ushort(val) [NSNumber numberWithUnsignedShort:(val)]
-
-#define $nonretained(val) [NSValue valueWithNonretainedObject:(val)]
-#define $pointer(val) [NSValue valueWithPointer:(val)]
-#define $point(val) [NSValue valueWithPoint:(val)]
-#define $range(val) [NSValue valueWithRange:(val)]
-#define $rect(val) [NSValue valueWithRect:(val)]
-#define $size(val) [NSValue valueWithSize:(val)]
-
-#define $safe(obj) ((NSNull *)(obj) == [NSNull null] ? nil : (obj))
View
71 ConciseKitSpecs/src/CKSingleton.h
@@ -1,71 +0,0 @@
-#define $shared(Klass) [Klass shared##Klass]
-
-#ifdef ALLOW_ALLOC_INIT_FOR_SINGLETONS
- #define $singleton(Klass)\
- \
- static Klass *shared##Klass = nil;\
- \
- + (Klass *)shared##Klass {\
- @synchronized(self) {\
- if(shared##Klass == nil) {\
- shared##Klass = [[super allocWithZone:NULL] initSingleton];\
- }\
- }\
- return shared##Klass;\
- }\
- \
- - (id)init {\
- if((self = [super init])) {\
- [self initSingleton];\
- }\
- return self;\
- }
-#else
- #define $singleton(Klass)\
- \
- static Klass *shared##Klass = nil;\
- \
- + (Klass *)shared##Klass {\
- @synchronized(self) {\
- if(shared##Klass == nil) {\
- shared##Klass = [[super allocWithZone:NULL] init];\
- }\
- }\
- return shared##Klass;\
- }\
- \
- + (id)allocWithZone:(NSZone *)zone {\
- return [[self shared##Klass] retain];\
- }\
- \
- - (id)copyWithZone:(NSZone *)zone {\
- return self;\
- }\
- \
- - (id)retain {\
- return self;\
- }\
- \
- - (NSUInteger)retainCount {\
- return NSUIntegerMax;\
- }\
- \
- - (void)release {}\
- \
- - (id)autorelease {\
- return self;\
- }\
- \
- + (BOOL)isShared##Klass##Present {\
- return shared##Klass != nil;\
- }\
- \
- - (id)init {\
- if(![[self class] isShared##Klass##Present]) {\
- if((self = [super init])) {\
- [self initSingleton];\
- }\
- }\
- return self;\
- }
-#endif
View
26 ConciseKitSpecs/src/ConciseKit.h
@@ -1,26 +0,0 @@
-#import <Foundation/Foundation.h>
-#import "CKMacros.h"
-#import "CKAdditions.h"
-#import "CKSingleton.h"
-
-@interface ConciseKit : NSObject {}
-
-+ (NSString *)homePath;
-+ (NSString *)desktopPath;
-+ (NSString *)documentPath;
-+ (NSString *)appPath;
-+ (NSString *)resourcePath;
-
-+ (BOOL)swizzleMethod:(SEL)originalSelector with:(SEL)anotherSelector in:(Class)klass;
-+ (BOOL)swizzleMethod:(SEL)originalSelector in:(Class)klass with:(SEL)anotherSelector in:(Class)anotherKlass;
-+ (BOOL)swizzleClassMethod:(SEL)originalSelector with:(SEL)anotherSelector in:(Class)klass;
-+ (BOOL)swizzleClassMethod:(SEL)originalSelector in:(Class)klass with:(SEL)anotherSelector in:(Class)anotherKlass;
-
-+ (void)waitUntil:(BOOL (^)(void))condition;
-+ (void)waitUntil:(BOOL (^)(void))condition timeOut:(NSTimeInterval)timeOut;
-+ (void)waitUntil:(BOOL (^)(void))condition timeOut:(NSTimeInterval)timeOut interval:(NSTimeInterval)interval;
-
-@end
-
-@interface $ : ConciseKit {}
-@end
View
94 ConciseKitSpecs/src/ConciseKit.m
@@ -1,94 +0,0 @@
-#import "ConciseKit.h"
-#import <objc/runtime.h>
-
-@implementation ConciseKit
-
-+ (NSString *)homePath {
- return NSHomeDirectory();
-}
-
-+ (NSString *)desktopPath {
- return [NSSearchPathForDirectoriesInDomains(NSDesktopDirectory, NSUserDomainMask, YES) objectAtIndex:0];
-}
-
-+ (NSString *)documentPath {
- return [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
-}
-
-+ (NSString *)appPath {
- return [[NSBundle mainBundle] bundlePath];
-}
-
-+ (NSString *)resourcePath {
- return [[NSBundle mainBundle] resourcePath];
-}
-
-+ (BOOL)swizzleMethod:(SEL)originalSelector with:(SEL)anotherSelector in:(Class)klass {
- return [self swizzleMethod:originalSelector in:klass with:anotherSelector in:klass];
-}
-
-+ (BOOL)swizzleMethod:(SEL)originalSelector in:(Class)klass with:(SEL)anotherSelector in:(Class)anotherKlass {
- Method originalMethod = class_getInstanceMethod(klass, originalSelector);
- Method anotherMethod = class_getInstanceMethod(anotherKlass, anotherSelector);
- if(!originalMethod || !anotherMethod) {
- return NO;
- }
- IMP originalMethodImplementation = class_getMethodImplementation(klass, originalSelector);
- IMP anotherMethodImplementation = class_getMethodImplementation(anotherKlass, anotherSelector);
- if(class_addMethod(klass, originalSelector, originalMethodImplementation, method_getTypeEncoding(originalMethod))) {
- originalMethod = class_getInstanceMethod(klass, originalSelector);
- }
- if(class_addMethod(anotherKlass, anotherSelector, anotherMethodImplementation, method_getTypeEncoding(anotherMethod))) {
- anotherMethod = class_getInstanceMethod(anotherKlass, anotherSelector);
- }
- method_exchangeImplementations(originalMethod, anotherMethod);
- return YES;
-}
-
-+ (BOOL)swizzleClassMethod:(SEL)originalSelector with:(SEL)anotherSelector in:(Class)klass {
- return [self swizzleClassMethod:originalSelector in:klass with:anotherSelector in:klass];
-}
-
-+ (BOOL)swizzleClassMethod:(SEL)originalSelector in:(Class)klass with:(SEL)anotherSelector in:(Class)anotherKlass {
- Method originalMethod = class_getClassMethod(klass, originalSelector);
- Method anotherMethod = class_getClassMethod(anotherKlass, anotherSelector);
- if(!originalMethod || !anotherMethod) {
- return NO;
- }
- Class metaClass = objc_getMetaClass(class_getName(klass));
- Class anotherMetaClass = objc_getMetaClass(class_getName(anotherKlass));
- IMP originalMethodImplementation = class_getMethodImplementation(metaClass, originalSelector);
- IMP anotherMethodImplementation = class_getMethodImplementation(anotherMetaClass, anotherSelector);
- if(class_addMethod(metaClass, originalSelector, originalMethodImplementation, method_getTypeEncoding(originalMethod))) {
- originalMethod = class_getClassMethod(klass, originalSelector);
- }
- if(class_addMethod(anotherMetaClass, anotherSelector, anotherMethodImplementation, method_getTypeEncoding(anotherMethod))) {
- anotherMethod = class_getClassMethod(anotherKlass, anotherSelector);
- }
- method_exchangeImplementations(originalMethod, anotherMethod);
- return YES;
-}
-
-+ (void)waitUntil:(BOOL (^)(void))condition {
- [self waitUntil:condition timeOut:10.0 interval:0.1];
-}
-
-+ (void)waitUntil:(BOOL (^)(void))condition timeOut:(NSTimeInterval)timeOut {
- [self waitUntil:condition timeOut:timeOut interval:0.1];
-}
-
-+ (void)waitUntil:(BOOL (^)(void))condition timeOut:(NSTimeInterval)timeOut interval:(NSTimeInterval)interval {
- NSTimeInterval sleptSoFar=0;
- while(1) {
- if(condition() || (sleptSoFar >= timeOut)) {
- return;
- }
- [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:interval]];
- sleptSoFar += interval;
- }
-}
-
-@end
-
-@implementation $
-@end
View
30 ConciseKitSpecs/src/NSArray+ConciseKit.h
@@ -1,30 +0,0 @@
-#import <Foundation/Foundation.h>
-
-@interface NSArray (ConciseKit)
-
-- (id)$first;
-- (id)$last;
-- (id)$at:(NSUInteger)index;
-- (NSArray *)$each:(void (^)(id obj))block;
-- (NSArray *)$eachWithIndex:(void (^)(id obj, NSUInteger idx))block;
-- (NSArray *)$eachWithStop:(void (^)(id obj, BOOL *stop))block;
-- (NSArray *)$eachWithIndexAndStop:(void (^)(id obj, NSUInteger idx, BOOL *stop))block;
-- (NSArray *)$map:(id (^)(id obj))block;
-- (NSArray *)$mapWithIndex:(id (^)(id obj, NSUInteger idx))block;
-- (id)$reduce:(id (^)(id memo, id obj))block;
-- (id)$reduceStartingAt:(id)starting with:(id (^)(id memo, id obj))block;
-- (NSArray *)$select:(BOOL(^)(id obj))block;
-- (id)$detect:(BOOL(^)(id obj))block;
-- (NSString *)$join;
-- (NSString *)$join:(NSString *)separator;
-
-@end
-
-@interface NSMutableArray (ConciseKit)
-
-- (NSMutableArray *)$push:(id)anObject;
-- (id)$pop;
-- (NSMutableArray *)$unshift:(id)anObject;
-- (id)$shift;
-
-@end
View
146 ConciseKitSpecs/src/NSArray+ConciseKit.m
@@ -1,146 +0,0 @@
-#import "NSArray+ConciseKit.h"
-
-@implementation NSArray (ConciseKit)
-
-- (id)$first {
- return [self objectAtIndex:0];
-}
-
-- (id)$last {
- return [self lastObject];
-}
-
-- (id)$at:(NSUInteger)index {
- return [self objectAtIndex:index];
-}
-
-- (NSArray *)$each:(void (^)(id obj))block {
- [self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
- block(obj);
- }];
- return self;
-}
-
-- (NSArray *)$eachWithIndex:(void (^)(id obj, NSUInteger idx))block {
- [self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
- block(obj, idx);
- }];
- return self;
-}
-
-- (NSArray *)$eachWithStop:(void (^)(id obj, BOOL *stop))block {
- [self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
- block(obj, stop);
- }];
- return self;
-}
-
-- (NSArray *)$eachWithIndexAndStop:(void (^)(id obj, NSUInteger idx, BOOL *stop))block {
- [self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
- block(obj, idx, stop);
- }];
- return self;
-}
-
-- (NSArray *)$map:(id (^)(id obj))block {
- __block NSMutableArray *array = [NSMutableArray arrayWithCapacity:[self count]];
- [self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
- [array addObject:block(obj)];
- }];
- return array;
-}
-
-- (NSArray *)$mapWithIndex:(id (^)(id obj, NSUInteger idx))block {
- __block NSMutableArray *array = [NSMutableArray arrayWithCapacity:[self count]];
- [self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
- [array addObject:block(obj, idx)];
- }];
- return array;
-}
-
-- (id)$reduce:(id (^)(id memo, id obj))block {
- __block id ret = nil;
- [self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
- if (idx == 0) {
- ret = obj;
- } else {
- ret = block(ret, obj);
- }
- }];
- return ret;
-}
-
-- (id)$reduceStartingAt:(id)starting with:(id (^)(id memo, id obj))block {
- __block id ret = starting;
- [self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
- ret = block(ret, obj);
- }];
- return ret;
-}
-
-- (NSArray *)$select:(BOOL(^)(id obj))block {
- __block NSMutableArray *array = [NSMutableArray arrayWithCapacity:[self count]];
- [self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
- if (block(obj)) {
- [array addObject:obj];
- }
- }];
- return [NSArray arrayWithArray:array];
-}
-
-- (id)$detect:(BOOL(^)(id obj))block {
- __block id ret = nil;
- [self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
- if (block(obj)) {
- *stop = YES;
- ret = obj;
- }
- }];
- return ret;
-}
-
-- (NSString *)$join {
- return [self componentsJoinedByString:@""];
-}
-
-- (NSString *)$join:(NSString *)separator {
- return [self componentsJoinedByString:separator];
-}
-
-@end
-
-@implementation NSMutableArray (ConciseKit)
-
-#ifndef __has_feature
- #define __has_feature(x) 0
-#endif
-#if __has_feature(objc_arc)
- #define IF_ARC(with, without) with
-#else
- #define IF_ARC(with, without) without
-#endif
-
-- (NSMutableArray *)$push:(id)anObject {
- [self addObject:anObject];
- return self;
-}
-
-- (id)$pop; {
- IF_ARC(id lastObject = [self lastObject];, id lastObject = [[[self lastObject] retain] autorelease];)
- [self removeLastObject];
- return lastObject;
-}
-
-- (NSMutableArray *)$unshift:(id)anObject {
- [self insertObject:anObject atIndex:0];
- return self;
-}
-
-- (id)$shift; {
- IF_ARC(id firstObject = [self objectAtIndex:0];, id firstObject = [[[self objectAtIndex:0] retain] autorelease];)
-
- [self removeObjectAtIndex:0];
- return firstObject;
-}
-
-@end
View
19 ConciseKitSpecs/src/NSDictionary+ConciseKit.h
@@ -1,19 +0,0 @@
-#import <Foundation/Foundation.h>
-
-@interface NSDictionary (ConciseKit)
-
-- (id)$for:(id)aKey;
-- (NSArray *)$keys;
-- (NSArray *)$values;
-- (NSDictionary *)$each:(void (^)(id key, id value))block;
-- (NSDictionary *)$eachWithStop:(void (^)(id key, id value, BOOL *stop))block;
-- (NSDictionary *)$eachKey:(void (^)(id key))block;
-- (NSDictionary *)$eachValue:(void (^)(id value))block;
-
-@end
-
-@interface NSMutableDictionary (ConciseKit)
-
-- (NSMutableDictionary *)$obj:(id)anObject for:(id)aKey;
-
-@end
View
54 ConciseKitSpecs/src/NSDictionary+ConciseKit.m
@@ -1,54 +0,0 @@
-#import "NSDictionary+ConciseKit.h"
-
-@implementation NSDictionary (ConciseKit)
-
-- (id)$for:(id)aKey {
- return [self objectForKey:aKey];
-}
-
-- (NSArray *)$keys {
- return [self allKeys];
-}
-
-- (NSArray *)$values {
- return [self allValues];
-}
-
-- (NSDictionary *)$each:(void (^)(id key, id value))block {
- [self enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL *stop) {
- block(key, value);
- }];
- return self;
-}
-
-- (NSDictionary *)$eachWithStop:(void (^)(id key, id value, BOOL *stop))block {
- [self enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL *stop) {
- block(key, value, stop);
- }];
- return self;
-}
-
-- (NSDictionary *)$eachKey:(void (^)(id key))block {
- [[self allKeys] enumerateObjectsUsingBlock:^(id key, NSUInteger idx, BOOL *stop) {
- block(key);
- }];
- return self;
-}
-
-- (NSDictionary *)$eachValue:(void (^)(id value))block {
- [[self allValues] enumerateObjectsUsingBlock:^(id value, NSUInteger idx, BOOL *stop) {
- block(value);
- }];
- return self;
-}
-
-@end
-
-@implementation NSMutableDictionary (ConciseKit)
-
-- (NSMutableDictionary *)$obj:(id)anObject for:(id)aKey {
- [self setObject:anObject forKey:aKey];
- return self;
-}
-
-@end
View
19 ConciseKitSpecs/src/NSString+ConciseKit.h
@@ -1,19 +0,0 @@
-#import <Foundation/Foundation.h>
-
-@interface NSString (ConciseKit)
-
-- (NSString *)$append:(NSString *)aString;
-- (NSString *)$prepend:(NSString *)aString;
-- (NSArray *)$split:(NSString *)aString;
-- (NSArray *)$split;
-
-@end
-
-@interface NSMutableString (ConciseKit)
-
-- (NSMutableString *)$append_:(NSString *)aString;
-- (NSMutableString *)$prepend_:(NSString *)aString;
-- (NSMutableString *)$insert:(NSString *)aString at:(NSUInteger)anIndex;
-- (NSMutableString *)$set:(NSString *)aString;
-
-@end
View
45 ConciseKitSpecs/src/NSString+ConciseKit.m
@@ -1,45 +0,0 @@
-#import "NSString+ConciseKit.h"
-
-@implementation NSString (ConciseKit)
-
-- (NSString *)$append:(NSString *)aString {
- return [self stringByAppendingString:aString];
-}
-
-- (NSString *)$prepend:(NSString *)aString {
- return [NSString stringWithFormat:@"%@%@", aString, self];
-}
-
-- (NSArray *)$split:(NSString *)aString {
- return [self componentsSeparatedByString:aString];
-}
-
-- (NSArray *)$split {
- return [self componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
-}
-
-@end
-
-@implementation NSMutableString (ConciseKit)
-
-- (NSMutableString *)$append_:(NSString *)aString {
- [self appendString:aString];
- return self;
-}
-
-- (NSMutableString *)$prepend_:(NSString *)aString {
- [self insertString:aString atIndex:0];
- return self;
-}
-
-- (NSMutableString *)$insert:(NSString *)aString at:(NSUInteger)anIndex {
- [self insertString:aString atIndex:anIndex];
- return self;
-}
-
-- (NSMutableString *)$set:(NSString *)aString {
- [self setString:aString];
- return self;
-}
-
-@end
View
4 src/CKMacros.h
@@ -12,12 +12,16 @@
#define $arr(...) [NSArray arrayWithObjects:__VA_ARGS__, nil]
#define $marr(...) [NSMutableArray arrayWithObjects:__VA_ARGS__, nil]
+#define $marrnew [NSMutableArray array]
#define $set(...) [NSSet setWithObjects:__VA_ARGS__, nil]
#define $mset(...) [NSMutableSet setWithObjects:__VA_ARGS__, nil]
+#define $msetnew [NSMutableSet set]
#define $dict(...) [NSDictionary dictionaryWithObjectsAndKeys:__VA_ARGS__, nil]
#define $mdict(...) [NSMutableDictionary dictionaryWithObjectsAndKeys:__VA_ARGS__, nil]
+#define $mdictnew [NSMutableDictionary dictionary]
#define $str(...) [NSString stringWithFormat:__VA_ARGS__]
#define $mstr(...) [NSMutableString stringWithFormat:__VA_ARGS__]
+#define $mstrnew [NSMutableString string]
#define $bool(val) [NSNumber numberWithBool:(val)]
#define $char(val) [NSNumber numberWithChar:(val)]
View
9 src/NSArray+ConciseKit.h
@@ -11,11 +11,20 @@
- (NSArray *)$eachWithIndexAndStop:(void (^)(id obj, NSUInteger idx, BOOL *stop))block;
- (NSArray *)$map:(id (^)(id obj))block;
- (NSArray *)$mapWithIndex:(id (^)(id obj, NSUInteger idx))block;
+- (id)$reduce:(id (^)(id memo, id obj))block;
+- (id)$reduceStartingAt:(id)starting with:(id (^)(id memo, id obj))block;
+- (NSArray *)$select:(BOOL(^)(id obj))block;
+- (id)$detect:(BOOL(^)(id obj))block;
+- (NSString *)$join;
+- (NSString *)$join:(NSString *)separator;
@end
@interface NSMutableArray (ConciseKit)
- (NSMutableArray *)$push:(id)anObject;
+- (id)$pop;
+- (NSMutableArray *)$unshift:(id)anObject;
+- (id)$shift;
@end
View
76 src/NSArray+ConciseKit.m
@@ -58,13 +58,89 @@ @implementation NSArray (ConciseKit)
return array;
}
+- (id)$reduce:(id (^)(id memo, id obj))block {
+ __block id ret = nil;
+ [self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
+ if (idx == 0) {
+ ret = obj;
+ } else {
+ ret = block(ret, obj);
+ }
+ }];
+ return ret;
+}
+
+- (id)$reduceStartingAt:(id)starting with:(id (^)(id memo, id obj))block {
+ __block id ret = starting;
+ [self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
+ ret = block(ret, obj);
+ }];
+ return ret;
+}
+
+- (NSArray *)$select:(BOOL(^)(id obj))block {
+ __block NSMutableArray *array = [NSMutableArray arrayWithCapacity:[self count]];
+ [self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
+ if (block(obj)) {
+ [array addObject:obj];
+ }
+ }];
+ return [NSArray arrayWithArray:array];
+}
+
+- (id)$detect:(BOOL(^)(id obj))block {
+ __block id ret = nil;
+ [self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
+ if (block(obj)) {
+ *stop = YES;
+ ret = obj;
+ }
+ }];
+ return ret;
+}
+
+- (NSString *)$join {
+ return [self componentsJoinedByString:@""];
+}
+
+- (NSString *)$join:(NSString *)separator {
+ return [self componentsJoinedByString:separator];
+}
+
@end
@implementation NSMutableArray (ConciseKit)
+#ifndef __has_feature
+ #define __has_feature(x) 0
+#endif
+#if __has_feature(objc_arc)
+ #define IF_ARC(with, without) with
+#else
+ #define IF_ARC(with, without) without
+#endif
+
- (NSMutableArray *)$push:(id)anObject {
[self addObject:anObject];
return self;
}
+- (id)$pop; {
+ IF_ARC(id lastObject = [self lastObject];, id lastObject = [[[self lastObject] retain] autorelease];)
+ [self removeLastObject];
+ return lastObject;
+}
+
+- (NSMutableArray *)$unshift:(id)anObject {
+ [self insertObject:anObject atIndex:0];
+ return self;
+}
+
+- (id)$shift; {
+ IF_ARC(id firstObject = [self objectAtIndex:0];, id firstObject = [[[self objectAtIndex:0] retain] autorelease];)
+
+ [self removeObjectAtIndex:0];
+ return firstObject;
+}
+
@end
View
6 src/NSDictionary+ConciseKit.h
@@ -3,6 +3,12 @@
@interface NSDictionary (ConciseKit)
- (id)$for:(id)aKey;
+- (NSArray *)$keys;
+- (NSArray *)$values;
+- (NSDictionary *)$each:(void (^)(id key, id value))block;
+- (NSDictionary *)$eachWithStop:(void (^)(id key, id value, BOOL *stop))block;
+- (NSDictionary *)$eachKey:(void (^)(id key))block;
+- (NSDictionary *)$eachValue:(void (^)(id value))block;
@end
View
36 src/NSDictionary+ConciseKit.m
@@ -6,6 +6,42 @@ @implementation NSDictionary (ConciseKit)
return [self objectForKey:aKey];
}
+- (NSArray *)$keys {
+ return [self allKeys];
+}
+
+- (NSArray *)$values {
+ return [self allValues];
+}
+
+- (NSDictionary *)$each:(void (^)(id key, id value))block {
+ [self enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL *stop) {
+ block(key, value);
+ }];
+ return self;
+}
+
+- (NSDictionary *)$eachWithStop:(void (^)(id key, id value, BOOL *stop))block {
+ [self enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL *stop) {
+ block(key, value, stop);
+ }];
+ return self;
+}
+
+- (NSDictionary *)$eachKey:(void (^)(id key))block {
+ [[self allKeys] enumerateObjectsUsingBlock:^(id key, NSUInteger idx, BOOL *stop) {
+ block(key);
+ }];
+ return self;
+}
+
+- (NSDictionary *)$eachValue:(void (^)(id value))block {
+ [[self allValues] enumerateObjectsUsingBlock:^(id value, NSUInteger idx, BOOL *stop) {
+ block(value);
+ }];
+ return self;
+}
+
@end
@implementation NSMutableDictionary (ConciseKit)
View
1 src/NSString+ConciseKit.h
@@ -5,6 +5,7 @@
- (NSString *)$append:(NSString *)aString;
- (NSString *)$prepend:(NSString *)aString;
- (NSArray *)$split:(NSString *)aString;
+- (NSArray *)$split;
@end
View
4 src/NSString+ConciseKit.m
@@ -14,6 +14,10 @@ @implementation NSString (ConciseKit)
return [self componentsSeparatedByString:aString];
}
+- (NSArray *)$split {
+ return [self componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
+}
+
@end
@implementation NSMutableString (ConciseKit)

0 comments on commit 4a70ea4

Please sign in to comment.
Something went wrong with that request. Please try again.