diff --git a/CocoaDeferred/CocoaDeferred.xcodeproj/project.pbxproj b/CocoaDeferred/CocoaDeferred.xcodeproj/project.pbxproj index 6d132ba..3b4c67a 100644 --- a/CocoaDeferred/CocoaDeferred.xcodeproj/project.pbxproj +++ b/CocoaDeferred/CocoaDeferred.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 45; + objectVersion = 46; objects = { /* Begin PBXBuildFile section */ @@ -14,10 +14,7 @@ 229C375E104C756800CFAA3F /* DKDeferred+UIKit.m in Sources */ = {isa = PBXBuildFile; fileRef = 229C3750104C756800CFAA3F /* DKDeferred+UIKit.m */; }; 229C375F104C756800CFAA3F /* DKDeferred+UIKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 229C3751104C756800CFAA3F /* DKDeferred+UIKit.h */; }; 229C3761104C756800CFAA3F /* DKDeferred.m in Sources */ = {isa = PBXBuildFile; fileRef = 229C3753104C756800CFAA3F /* DKDeferred.m */; }; - 229C3763104C756800CFAA3F /* DKDeferred+JSON.h in Headers */ = {isa = PBXBuildFile; fileRef = 229C3755104C756800CFAA3F /* DKDeferred+JSON.h */; }; - 229C3764104C756800CFAA3F /* DKDeferred.h in Headers */ = {isa = PBXBuildFile; fileRef = 229C3756104C756800CFAA3F /* DKDeferred.h */; }; 229C3765104C756800CFAA3F /* DKCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 229C3757104C756800CFAA3F /* DKCallback.h */; }; - 229C3766104C756800CFAA3F /* DKMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 229C3758104C756800CFAA3F /* DKMacros.h */; }; 229C3767104C756800CFAA3F /* DKCallback.m in Sources */ = {isa = PBXBuildFile; fileRef = 229C3759104C756800CFAA3F /* DKCallback.m */; }; 229C3773104C76D400CFAA3F /* UIImage+DKDeferred.m in Sources */ = {isa = PBXBuildFile; fileRef = 229C3771104C76D400CFAA3F /* UIImage+DKDeferred.m */; }; 229C3774104C76D400CFAA3F /* UIImage+DKDeferred.h in Headers */ = {isa = PBXBuildFile; fileRef = 229C3772104C76D400CFAA3F /* UIImage+DKDeferred.h */; }; @@ -44,6 +41,7 @@ 229C38CA104DE5C400CFAA3F /* DKDeferredTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 229C38C9104DE5C400CFAA3F /* DKDeferredTests.m */; }; 229C38D0104DE5E400CFAA3F /* DKDeferredJSONTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 229C38CF104DE5E400CFAA3F /* DKDeferredJSONTests.m */; }; 229C390C104DEAC800CFAA3F /* DKCallbackTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 229C390B104DEAC800CFAA3F /* DKCallbackTests.m */; }; + 9AFE7D7B1508961D005CBF23 /* DKMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AFE7D77150879E6005CBF23 /* DKMacros.h */; settings = {ATTRIBUTES = (Private, ); }; }; AA747D9F0F9514B9006C5449 /* CocoaDeferred_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = AA747D9E0F9514B9006C5449 /* CocoaDeferred_Prefix.pch */; }; AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AACBBE490F95108600F1A2B1 /* Foundation.framework */; }; /* End PBXBuildFile section */ @@ -73,7 +71,6 @@ 229C3755104C756800CFAA3F /* DKDeferred+JSON.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "DKDeferred+JSON.h"; path = "Source/DeferredKit/DKDeferred+JSON.h"; sourceTree = SOURCE_ROOT; }; 229C3756104C756800CFAA3F /* DKDeferred.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DKDeferred.h; path = Source/DeferredKit/DKDeferred.h; sourceTree = SOURCE_ROOT; }; 229C3757104C756800CFAA3F /* DKCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DKCallback.h; path = Source/DeferredKit/DKCallback.h; sourceTree = SOURCE_ROOT; }; - 229C3758104C756800CFAA3F /* DKMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DKMacros.h; path = Source/DeferredKit/DKMacros.h; sourceTree = SOURCE_ROOT; }; 229C3759104C756800CFAA3F /* DKCallback.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DKCallback.m; path = Source/DeferredKit/DKCallback.m; sourceTree = SOURCE_ROOT; }; 229C3771104C76D400CFAA3F /* UIImage+DKDeferred.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UIImage+DKDeferred.m"; path = "Source/DeferredKit/UIImage+DKDeferred.m"; sourceTree = SOURCE_ROOT; }; 229C3772104C76D400CFAA3F /* UIImage+DKDeferred.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UIImage+DKDeferred.h"; path = "Source/DeferredKit/UIImage+DKDeferred.h"; sourceTree = SOURCE_ROOT; }; @@ -105,6 +102,7 @@ 229C38CF104DE5E400CFAA3F /* DKDeferredJSONTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DKDeferredJSONTests.m; sourceTree = ""; }; 229C390A104DEAC800CFAA3F /* DKCallbackTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DKCallbackTests.h; sourceTree = ""; }; 229C390B104DEAC800CFAA3F /* DKCallbackTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DKCallbackTests.m; sourceTree = ""; }; + 9AFE7D77150879E6005CBF23 /* DKMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DKMacros.h; path = Source/DeferredKit/DKMacros.h; sourceTree = SOURCE_ROOT; }; AA747D9E0F9514B9006C5449 /* CocoaDeferred_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CocoaDeferred_Prefix.pch; sourceTree = SOURCE_ROOT; }; AACBBE490F95108600F1A2B1 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; D2AAC07E0554694100DB518D /* libDeferredKit.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libDeferredKit.a; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -149,7 +147,6 @@ 32C88DFF0371C24200C91783 /* Other Sources */, 0867D69AFE84028FC02AAC07 /* Frameworks */, 034768DFFF38A50411DB9C8B /* Products */, - 229C37A3104DCFFF00CFAA3F /* UIKit.framework */, 229C389E104DE23400CFAA3F /* DeferredTest-Info.plist */, ); name = CocoaDeferred; @@ -158,6 +155,7 @@ 0867D69AFE84028FC02AAC07 /* Frameworks */ = { isa = PBXGroup; children = ( + 229C37A3104DCFFF00CFAA3F /* UIKit.framework */, AACBBE490F95108600F1A2B1 /* Foundation.framework */, ); name = Frameworks; @@ -168,6 +166,7 @@ children = ( 229C38AB104DE34D00CFAA3F /* Tests */, 229C3809104DDE4600CFAA3F /* JSON */, + 9AFE7D77150879E6005CBF23 /* DKMacros.h */, 229C374C104C756800CFAA3F /* DeferredKit.h */, 229C3771104C76D400CFAA3F /* UIImage+DKDeferred.m */, 229C3772104C76D400CFAA3F /* UIImage+DKDeferred.h */, @@ -180,7 +179,6 @@ 229C3755104C756800CFAA3F /* DKDeferred+JSON.h */, 229C3756104C756800CFAA3F /* DKDeferred.h */, 229C3757104C756800CFAA3F /* DKCallback.h */, - 229C3758104C756800CFAA3F /* DKMacros.h */, 229C3759104C756800CFAA3F /* DKCallback.m */, ); name = Classes; @@ -255,10 +253,7 @@ AA747D9F0F9514B9006C5449 /* CocoaDeferred_Prefix.pch in Headers */, 229C375A104C756800CFAA3F /* DeferredKit.h in Headers */, 229C375F104C756800CFAA3F /* DKDeferred+UIKit.h in Headers */, - 229C3763104C756800CFAA3F /* DKDeferred+JSON.h in Headers */, - 229C3764104C756800CFAA3F /* DKDeferred.h in Headers */, 229C3765104C756800CFAA3F /* DKCallback.h in Headers */, - 229C3766104C756800CFAA3F /* DKMacros.h in Headers */, 229C3774104C76D400CFAA3F /* UIImage+DKDeferred.h in Headers */, 229C3821104DDE5F00CFAA3F /* SBJSON.h in Headers */, 229C3824104DDE5F00CFAA3F /* JSON.h in Headers */, @@ -267,6 +262,7 @@ 229C382A104DDE5F00CFAA3F /* SBJsonWriter.h in Headers */, 229C382B104DDE5F00CFAA3F /* NSObject+SBJSON.h in Headers */, 229C382C104DDE5F00CFAA3F /* NSString+SBJSON.h in Headers */, + 9AFE7D7B1508961D005CBF23 /* DKMacros.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -314,9 +310,16 @@ /* Begin PBXProject section */ 0867D690FE84028FC02AAC07 /* Project object */ = { isa = PBXProject; + attributes = { + LastUpgradeCheck = 0430; + }; buildConfigurationList = 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "CocoaDeferred" */; - compatibilityVersion = "Xcode 3.1"; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; hasScannedForEncodings = 1; + knownRegions = ( + en, + ); mainGroup = 0867D691FE84028FC02AAC07 /* CocoaDeferred */; productRefGroup = 034768DFFF38A50411DB9C8B /* Products */; projectDirPath = ""; @@ -407,13 +410,14 @@ COPY_PHASE_STRIP = NO; DSTROOT = /tmp/CocoaDeferred.dst; GCC_DYNAMIC_NO_PIC = NO; - GCC_ENABLE_FIX_AND_CONTINUE = YES; GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = CocoaDeferred_Prefix.pch; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; INSTALL_PATH = /usr/local/lib; PRODUCT_NAME = DeferredKit; + SDKROOT = iphoneos; }; name = Debug; }; @@ -426,8 +430,10 @@ GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = CocoaDeferred_Prefix.pch; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; INSTALL_PATH = /usr/local/lib; PRODUCT_NAME = CocoaDeferred; + SDKROOT = iphoneos; }; name = Release; }; @@ -441,8 +447,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; HEADER_SEARCH_PATHS = ./Source; OTHER_LDFLAGS = "-ObjC"; - PREBINDING = NO; - SDKROOT = iphoneos3.0; + SDKROOT = iphoneos; }; name = Debug; }; @@ -454,8 +459,7 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; OTHER_LDFLAGS = "-ObjC"; - PREBINDING = NO; - SDKROOT = iphoneos3.0; + SDKROOT = iphoneos; }; name = Release; }; @@ -478,9 +482,8 @@ "-framework", UIKit, ); - PREBINDING = NO; PRODUCT_NAME = DeferredTest; - SDKROOT = iphoneos3.0; + SDKROOT = iphoneos; }; name = Debug; }; @@ -491,7 +494,6 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_ENABLE_FIX_AND_CONTINUE = NO; GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/UIKit.framework/Headers/UIKit.h"; INFOPLIST_FILE = "DeferredTest-Info.plist"; @@ -502,9 +504,8 @@ "-framework", UIKit, ); - PREBINDING = NO; PRODUCT_NAME = DeferredTest; - SDKROOT = iphoneos2.1; + SDKROOT = iphoneos; ZERO_LINK = NO; }; name = Release; diff --git a/CocoaDeferred/Source/DeferredKit/DKDeferred+JSON.h b/CocoaDeferred/Source/DeferredKit/DKDeferred+JSON.h index 4b3b7c7..a1d65db 100644 --- a/CocoaDeferred/Source/DeferredKit/DKDeferred+JSON.h +++ b/CocoaDeferred/Source/DeferredKit/DKDeferred+JSON.h @@ -6,8 +6,9 @@ // #import -#import "JSON/JSON.h" +#import "JSON.h" #import "DKDeferred.h" +#import @interface DKDeferred (JSONAdditions) @@ -77,6 +78,8 @@ */ - (id):(NSArray *)args; +- (id)callWithName:(NSString *)name args:(NSArray *)args; + @end diff --git a/CocoaDeferred/Source/DeferredKit/DKDeferred+JSON.m b/CocoaDeferred/Source/DeferredKit/DKDeferred+JSON.m index 1f33666..329a397 100644 --- a/CocoaDeferred/Source/DeferredKit/DKDeferred+JSON.m +++ b/CocoaDeferred/Source/DeferredKit/DKDeferred+JSON.m @@ -87,10 +87,14 @@ - (NSString *)description { } - (id):(NSArray *)args { + CFUUIDRef uuidObj = CFUUIDCreate(nil); +NSString *uuidStr = (NSString*)CFUUIDCreateString(NULL, uuidObj); + NSDictionary *methodCall = dict_(serviceName, @"method", args, @"params", - _uuid1(), @"id", + uuidStr, @"id", @"1.1", @"version"); +CFRelease(uuidObj); NSError *error = nil; NSString *post = [[[SBJSON alloc] init] stringWithObject:methodCall error:&error]; if (error) diff --git a/CocoaDeferred/Source/DeferredKit/DKDeferred.m b/CocoaDeferred/Source/DeferredKit/DKDeferred.m index 07db070..bdd66a7 100644 --- a/CocoaDeferred/Source/DeferredKit/DKDeferred.m +++ b/CocoaDeferred/Source/DeferredKit/DKDeferred.m @@ -8,6 +8,15 @@ #import "DKDeferred.h" #import +/** + * Creates a new NSString containing a UUID + **/ +static inline NSString* _uuid1() { + CFUUIDRef uuid = CFUUIDCreate(nil); + NSString *uuidString = (NSString *)CFUUIDCreateString(nil, uuid); + CFRelease(uuid); + return [uuidString autorelease]; +} NSString* md5(NSString *str) { const char *cStr = [str UTF8String]; @@ -344,7 +353,7 @@ - (void)_fire { if (f == [NSNull null]) continue; id newResult = [(id)f :result]; - result = (newResult == nil) ? [NSNull null] : newResult; + result = (newResult) ? [NSNull null] : newResult; _fired = [result isKindOfClass:[NSError class]] ? 1 : 0; if ([result isKindOfClass:[self class]]) { cb = callbackTS(self, _continueChain:); @@ -983,10 +992,10 @@ - (id)initWithDirectory:(NSString *)_dir NSString *cachesPath = [paths objectAtIndex:0]; dir = [[cachesPath stringByAppendingPathComponent:_dir] retain]; if (![fm fileExistsAtPath:cachesPath]) { - [fm createDirectoryAtPath:cachesPath attributes:nil]; + [fm createDirectoryAtPath:cachesPath withIntermediateDirectories:NO attributes:nil error:nil]; } if (![fm fileExistsAtPath:dir]) { - [fm createDirectoryAtPath:dir attributes:nil]; + [fm createDirectoryAtPath:dir withIntermediateDirectories:NO attributes:nil error:nil]; } } return self; @@ -1001,7 +1010,7 @@ - (void)dealloc { - (void)_cull { if ([self _getNumEntries] > maxEntries) { NSFileManager *fm = [NSFileManager defaultManager]; - NSArray *fileList = [fm directoryContentsAtPath:dir]; + NSArray *fileList = [fm contentsOfDirectoryAtPath:dir error:nil]; NSMutableArray *doomed = [NSMutableArray array]; int count = 0; for (NSString *path in fileList) { @@ -1019,7 +1028,7 @@ - (void)_cull { - (int)_getNumEntries { NSArray *fileNames = [[NSFileManager defaultManager] - directoryContentsAtPath:dir]; + contentsOfDirectoryAtPath:dir error:nil]; if (!fileNames) return 0; return [fileNames count]; diff --git a/CocoaDeferred/Source/DeferredKit/DKMacros.h b/CocoaDeferred/Source/DeferredKit/DKMacros.h index 9ed3bcf..8b3f3bc 100644 --- a/CocoaDeferred/Source/DeferredKit/DKMacros.h +++ b/CocoaDeferred/Source/DeferredKit/DKMacros.h @@ -30,7 +30,7 @@ static inline id _curryTS(id target, SEL selector, ...) { va_start(argumentList, selector); id arg; int i = 0; - while (arg = va_arg(argumentList, id)) { + while ((arg = va_arg(argumentList, id))) { //NSLog(@"arg:%@", arg); [invocation setArgument:&arg atIndex:i + 2]; i++; @@ -67,13 +67,5 @@ static inline id _curryTS(id target, SEL selector, ...) { #define EMPTY_ARRAY [NSArray array] #endif -/** - * Creates a new NSString containing a UUID - **/ -static inline NSString* _uuid1() { - CFUUIDRef uuid = CFUUIDCreate(nil); - NSString *uuidString = (NSString *)CFUUIDCreateString(nil, uuid); - CFRelease(uuid); - return [uuidString autorelease]; -} + #endif \ No newline at end of file