Permalink
Browse files

Merge pull request #3 from serebryakov-av/master

iOS Support
  • Loading branch information...
2 parents 6f5e508 + 60ccb35 commit 57f9d1bf7b44e29ae13be28327f94abf94be2161 @rentzsch committed Nov 4, 2011
Showing with 15 additions and 1 deletion.
  1. +15 −1 JRSwizzle.m
View
@@ -2,7 +2,13 @@
// Some rights reserved: http://opensource.org/licenses/mit-license.php
#import "JRSwizzle.h"
-#import <objc/objc-class.h>
+
+#if TARGET_OS_IPHONE
+ #import <objc/runtime.h>
+ #import <objc/message.h>
+#else
+ #import <objc/objc-class.h>
+#endif
#define SetNSErrorFor(FUNC, ERROR_VAR, FORMAT,...) \
if (ERROR_VAR) { \
@@ -25,13 +31,21 @@ + (BOOL)jr_swizzleMethod:(SEL)origSel_ withMethod:(SEL)altSel_ error:(NSError**)
#if OBJC_API_VERSION >= 2
Method origMethod = class_getInstanceMethod(self, origSel_);
if (!origMethod) {
+#if TARGET_OS_IPHONE
+ SetNSError(error_, @"original method %@ not found for class %@", NSStringFromSelector(origSel_), [self class]);
+#else
SetNSError(error_, @"original method %@ not found for class %@", NSStringFromSelector(origSel_), [self className]);
+#endif
return NO;
}
Method altMethod = class_getInstanceMethod(self, altSel_);
if (!altMethod) {
+#if TARGET_OS_IPHONE
+ SetNSError(error_, @"alternate method %@ not found for class %@", NSStringFromSelector(altSel_), [self class]);
+#else
SetNSError(error_, @"alternate method %@ not found for class %@", NSStringFromSelector(altSel_), [self className]);
+#endif
return NO;
}

0 comments on commit 57f9d1b

Please sign in to comment.