Permalink
Browse files

more iOS Compatibility

the following classes now compile on iOS
-CWSHA1Utilities
-CWDateUtilities (2 functions need work to work on iOS)
-NSStringAdditions
-NSSetAdditions (1 API will never work on iOS)
-CWGraphicsFoundation
-CWURLUtilities (incomplete, no Base64 imp)
-CWURLReqest (incomplete, no auth header because of no Base64 imp)
- NSRecursiveLockAdditions
  • Loading branch information...
1 parent 3f3b7d0 commit 89feeb243c8f7873553c740b9ba9abc814ba463f @Machx committed Jan 16, 2012
@@ -26,8 +26,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-
-#if TARGET_OS_MAC
+#if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
static const NSInteger kPidNotFound = -1;
@@ -37,7 +36,7 @@ static const NSInteger kPidNotFound = -1;
+(NSInteger)pidForApplication:(NSString *)appName;
+(NSString *)bundleIdentifierForApplication:(NSString *)appName;
+(NSInteger)executableArchitectureForApplication:(NSString *)appName;
-//+(NSRunningApplication *)runningAppInstanceForApp:(NSString *)appName;
-//+(NSImage *)iconForApplication:(NSString *)appName;
++(NSRunningApplication *)runningAppInstanceForApp:(NSString *)appName;
++(NSImage *)iconForApplication:(NSString *)appName;
@end
-#endif
+#endif
View
@@ -39,7 +39,7 @@ @implementation NSString (CWBase64Encoding)
*/
- (NSString *)cw_base64EncodedString {
if (self == nil) { return nil; }
-
+
SecTransformRef encoder;
CFErrorRef error = NULL;
@@ -80,6 +80,7 @@ + (NSDate *) dateFromString:(NSString *)dateString withDateFormat:(NSString *)da
@end
+#if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
/**
* Returns a NSString with a description of the NSDate object
*
@@ -98,6 +99,7 @@ + (NSDate *) dateFromString:(NSString *)dateString withDateFormat:(NSString *)da
locale:nil];
return desc;
}
+#endif
/**
* Creates a NSDate object from the values passed in for date components
@@ -143,6 +145,7 @@ + (NSDate *) dateFromString:(NSString *)dateString withDateFormat:(NSString *)da
return nil;
}
+#if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
/**
* Returns a NSString using NSDates description format
*
@@ -164,3 +167,4 @@ + (NSDate *) dateFromString:(NSString *)dateString withDateFormat:(NSString *)da
return dateString;
}
+#endif
@@ -28,10 +28,10 @@ THE SOFTWARE.
*/
-#if TARGET_OS_IPHONE
-#import <UIKit/UIKit.h>
-#elif TARGET_OS_MAC
+#if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
#import <Cocoa/Cocoa.h>
+#else
+#import <UIKit/UIKit.h>
#endif
CGRect CWCenteredRect(CGRect smallRect, CGRect largeRect);
@@ -44,7 +44,11 @@ CGRect CWCenteredRect(CGRect smallRect, CGRect largeRect) {
Easy way to return the CGContextRef inside a NSView
*/
inline CGContextRef CWCurrentCGContext() {
+#if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
return (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
+#else
+ return UIGraphicsGetCurrentContext();
+#endif
}
/**
@@ -43,8 +43,13 @@ static const NSInteger kCWSimpleURLRequestNoHostError = 404;
//API
-(id)initWithHost:(NSString *)host;
+#if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
+// Base64 imp on Lion used SecTransform which is not available
+// on iOS, will need to come up with a iOS specific implementation
+// before this api will be available
-(void)setAuthorizationHeaderLogin:(NSString *)login
andPassword:(NSString *)passwd;
+#endif
-(NSData *)startSynchronousConnection;
@@ -109,6 +109,7 @@ -(NSString *)description {
CWBOOLString([self connectionIsFinished])];
}
+#if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
/**
Creates the Base64 encoded http authorization header for the instance request
@@ -129,6 +130,7 @@ -(void)setAuthorizationHeaderLogin:(NSString *)login
}
}
}
+#endif
-(NSMutableURLRequest *)_createInternalURLRequest {
/**
@@ -31,7 +31,9 @@
NSURL *CWURL(NSString * urlFormat,...);
+#if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
NSString *CWURLAuthorizationHeaderString(NSString *login, NSString *password);
+#endif
@interface CWURLUtilities : NSObject
@@ -52,6 +52,7 @@ of this software and associated documentation files (the "Software"), to deal
return _urlValue;
}
+#if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
/**
Creates a authorization header string like "Basic {base64encodedlogin}"
@@ -75,6 +76,7 @@ of this software and associated documentation files (the "Software"), to deal
}
return nil;
}
+#endif
static NSString * const kCWURLUtiltyErrorDomain = @"com.Zangetsu.CWURLUtilities";
@@ -42,7 +42,7 @@
-(NSSet *)cw_findAllWithBlock:(BOOL (^)(id obj))block;
-#if !TARGET_OS_IPHONE
+#if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
-(NSHashTable *)cw_findAllIntoWeakRefsWithBlock:(BOOL (^)(id))block;
#endif
@@ -120,6 +120,7 @@ -(NSSet *)cw_findAllWithBlock:(BOOL (^)(id obj))block {
return results;
}
+#if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
/**
experimental method
like cw_find but instead uses NSHashTable to store pointers to
@@ -138,6 +139,7 @@ -(NSHashTable *)cw_findAllIntoWeakRefsWithBlock:(BOOL (^)(id))block {
return results;
}
+#endif
/**
cw_mapSet basically maps a set by enumerating
@@ -28,26 +28,26 @@
*/
#import "CWMacros.h"
-//#import "CWSHA1Utilities.h"
-//#import "CWDateUtilities.h" //IN_PROGRESS_IOS
-//#import "NSStringAdditions.h"
+#import "CWSHA1Utilities.h"
+#import "CWDateUtilities.h" //IN_PROGRESS_IOS (date formatter)
+#import "NSStringAdditions.h"
#import "NSArrayAdditions.h"
#import "NSDictionaryAdditions.h"
//#import "CWSystemInfo.h"
-//#import "NSSetAdditions.h"
+#import "NSSetAdditions.h"
//#import "NSURLConnectionAdditions.h"
//#import "CWDebugUtilities.h"
#import "NSObjectAdditions.h"
#import "CWFoundation.h"
//#import "CWPathUtilities.h"
#import "CWErrorUtilities.h"
-//#import "CWGraphicsFoundation.h"
+#import "CWGraphicsFoundation.h"
//#import "CWMD5Utilities.h"
#import "NSDataAdditions.h"
//#import "CWCoreDataCenter.h"
//#import "NSManagedObjectAdditions.h"
//#import "CWExceptionUtilities.h"
-//#import "CWURLUtilities.h"
+#import "CWURLUtilities.h" //IN_PROGRESS_IOS (base64 imp)
#import "CWRuntimeUtilities.h"
//#import "CWReachability.h"
//#import "NSDateAddtions.h"
@@ -60,9 +60,10 @@
//#import "CWZLib.h"
//#import "NSOperationQueueAdditions.h"
#import "CWQueue.h"
-//#import "CWURLRequest.h"
+#import "CWURLRequest.h"
//#import "NSMutableURLRequestAdditions.h"
-//#import "NSRecursiveLockAdditions.h"
+#import "NSRecursiveLockAdditions.h"
//#import "NSManagedObjectContextAdditions.h"
// NO_COMPILE_IOS
//#import "CWTask.h" // NO_NSTASK_IOS
+//#import "CWApplicationRegistry.h" //NO_NSWORKSPACE_IOS
@@ -128,6 +128,18 @@
B8C18303138C1AF900A7EF7C /* CWStack.m in Sources */ = {isa = PBXBuildFile; fileRef = B8C18301138C1AF900A7EF7C /* CWStack.m */; };
B8C1F9BE1426F27F0065369B /* CWBase64Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = B8C1F9BD1426F27F0065369B /* CWBase64Tests.m */; };
B8C320CF12A1B77F00219E4A /* CWNSArrayTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B8C320CE12A1B77F00219E4A /* CWNSArrayTests.m */; };
+ B8C5B94914C484F5000E0A88 /* NSStringAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = B837BC181284FDC0009215D7 /* NSStringAdditions.m */; };
+ B8C5B94B14C484F9000E0A88 /* NSStringAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = B837BC171284FDC0009215D7 /* NSStringAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ B8C5B94C14C48536000E0A88 /* NSRecursiveLockAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = B8635FF9149C505800D6741D /* NSRecursiveLockAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ B8C5B94D14C4853C000E0A88 /* NSRecursiveLockAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = B8635FFA149C505800D6741D /* NSRecursiveLockAdditions.m */; };
+ B8C5B94E14C4864D000E0A88 /* CWSHA1Utilities.h in Headers */ = {isa = PBXBuildFile; fileRef = B890142911D992F000705CE4 /* CWSHA1Utilities.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ B8C5B94F14C48653000E0A88 /* CWSHA1Utilities.m in Sources */ = {isa = PBXBuildFile; fileRef = B890142A11D992F000705CE4 /* CWSHA1Utilities.m */; };
+ B8C5B95014C486E0000E0A88 /* NSSetAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = B88C1195129239C500B49835 /* NSSetAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ B8C5B95114C486E5000E0A88 /* NSSetAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = B88C1196129239C500B49835 /* NSSetAdditions.m */; };
+ B8C5B95414C48E09000E0A88 /* CWURLUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = B81BFF8A1305A7F1001A4BCF /* CWURLUtilities.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ B8C5B95514C48E0F000E0A88 /* CWURLUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = B81BFF8B1305A7F2001A4BCF /* CWURLUtilities.m */; };
+ B8C5B95614C48E3F000E0A88 /* CWDateUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = B84995C5128396E1001206E1 /* CWDateUtilities.m */; };
+ B8C5B95714C48E43000E0A88 /* CWDateUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = B84995C4128396E1001206E1 /* CWDateUtilities.h */; settings = {ATTRIBUTES = (Public, ); }; };
B8D1F36413AA54630099BBDC /* CWDateUtilitiesTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B8D1F36313AA54630099BBDC /* CWDateUtilitiesTests.m */; };
B8D9193A133E3C9D009AC4AC /* CWReachability.h in Headers */ = {isa = PBXBuildFile; fileRef = B8D91938133E3C9D009AC4AC /* CWReachability.h */; settings = {ATTRIBUTES = (Public, ); }; };
B8D9193B133E3C9D009AC4AC /* CWReachability.m in Sources */ = {isa = PBXBuildFile; fileRef = B8D91939133E3C9D009AC4AC /* CWReachability.m */; };
@@ -139,6 +151,10 @@
B8E3880814C4759D00F6D2A8 /* NSDateAddtions.h in Headers */ = {isa = PBXBuildFile; fileRef = B8380E4013452C18009988F5 /* NSDateAddtions.h */; settings = {ATTRIBUTES = (Public, ); }; };
B8E3880914C475EC00F6D2A8 /* NSDictionaryAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = B85889A0128E04E9002AC417 /* NSDictionaryAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
B8E3880A14C475F300F6D2A8 /* NSDictionaryAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = B85889A1128E04E9002AC417 /* NSDictionaryAdditions.m */; };
+ B8E3881514C47E2600F6D2A8 /* CWURLRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = B818BBFA1497A49800C71A61 /* CWURLRequest.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ B8E3881614C47E2B00F6D2A8 /* CWURLRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = B818BBFB1497A49800C71A61 /* CWURLRequest.m */; };
+ B8E3881714C4837F00F6D2A8 /* CWGraphicsFoundation.h in Headers */ = {isa = PBXBuildFile; fileRef = B849506C12C52F6E00098684 /* CWGraphicsFoundation.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ B8E3881814C4838700F6D2A8 /* CWGraphicsFoundation.m in Sources */ = {isa = PBXBuildFile; fileRef = B849506D12C52F6E00098684 /* CWGraphicsFoundation.m */; };
B8E654B5136CD6F8000672A0 /* CWCFConversionMacros.h in Headers */ = {isa = PBXBuildFile; fileRef = B8E654B4136CD6F8000672A0 /* CWCFConversionMacros.h */; settings = {ATTRIBUTES = (Public, ); }; };
B8E71A9512C42A10003D09A7 /* CWErrorUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = B8E71A9312C42A10003D09A7 /* CWErrorUtilities.h */; settings = {ATTRIBUTES = (Public, ); }; };
B8E71A9612C42A10003D09A7 /* CWErrorUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = B8E71A9412C42A10003D09A7 /* CWErrorUtilities.m */; };
@@ -300,6 +316,7 @@
B8D91939133E3C9D009AC4AC /* CWReachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CWReachability.m; path = Source/CWReachability.m; sourceTree = "<group>"; };
B8D9196C133E493A009AC4AC /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
B8DC9A93134A6DF200501FC1 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
+ B8E3881314C47BD000F6D2A8 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/System/Library/Frameworks/Security.framework; sourceTree = DEVELOPER_DIR; };
B8E654B4136CD6F8000672A0 /* CWCFConversionMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CWCFConversionMacros.h; path = Source/CWCFConversionMacros.h; sourceTree = "<group>"; };
B8E71A9312C42A10003D09A7 /* CWErrorUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CWErrorUtilities.h; path = Source/CWErrorUtilities.h; sourceTree = "<group>"; };
B8E71A9412C42A10003D09A7 /* CWErrorUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CWErrorUtilities.m; path = Source/CWErrorUtilities.m; sourceTree = "<group>"; };
@@ -528,6 +545,7 @@
B869BAFA14C3AA5A00ED2908 /* Frameworks */ = {
isa = PBXGroup;
children = (
+ B8E3881314C47BD000F6D2A8 /* Security.framework */,
B869BB2714C3B6C800ED2908 /* SenTestingKit.framework */,
B869BB2514C3B6AF00ED2908 /* UIKit.framework */,
B869BAFB14C3AA5A00ED2908 /* Foundation.framework */,
@@ -732,6 +750,14 @@
B8E3880614C4757300F6D2A8 /* NSDataAdditions.h in Headers */,
B8E3880814C4759D00F6D2A8 /* NSDateAddtions.h in Headers */,
B8E3880914C475EC00F6D2A8 /* NSDictionaryAdditions.h in Headers */,
+ B8E3881514C47E2600F6D2A8 /* CWURLRequest.h in Headers */,
+ B8E3881714C4837F00F6D2A8 /* CWGraphicsFoundation.h in Headers */,
+ B8C5B94B14C484F9000E0A88 /* NSStringAdditions.h in Headers */,
+ B8C5B94C14C48536000E0A88 /* NSRecursiveLockAdditions.h in Headers */,
+ B8C5B94E14C4864D000E0A88 /* CWSHA1Utilities.h in Headers */,
+ B8C5B95014C486E0000E0A88 /* NSSetAdditions.h in Headers */,
+ B8C5B95414C48E09000E0A88 /* CWURLUtilities.h in Headers */,
+ B8C5B95714C48E43000E0A88 /* CWDateUtilities.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -961,6 +987,14 @@
B8E3880414C4756F00F6D2A8 /* NSDataAdditions.m in Sources */,
B8E3880714C4759900F6D2A8 /* NSDateAddtions.m in Sources */,
B8E3880A14C475F300F6D2A8 /* NSDictionaryAdditions.m in Sources */,
+ B8E3881614C47E2B00F6D2A8 /* CWURLRequest.m in Sources */,
+ B8E3881814C4838700F6D2A8 /* CWGraphicsFoundation.m in Sources */,
+ B8C5B94914C484F5000E0A88 /* NSStringAdditions.m in Sources */,
+ B8C5B94D14C4853C000E0A88 /* NSRecursiveLockAdditions.m in Sources */,
+ B8C5B94F14C48653000E0A88 /* CWSHA1Utilities.m in Sources */,
+ B8C5B95114C486E5000E0A88 /* NSSetAdditions.m in Sources */,
+ B8C5B95514C48E0F000E0A88 /* CWURLUtilities.m in Sources */,
+ B8C5B95614C48E3F000E0A88 /* CWDateUtilities.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

0 comments on commit 89feeb2

Please sign in to comment.