Revision: 4291
http://skim-app.svn.sourceforge.net/skim-app/?rev=4291&view=rev
Author: hofman
Date: 2008-07-24 10:45:49 +0000 (Thu, 24 Jul 2008)
Log Message:
-----------
simplify and correct method exchange
Modified Paths:
--------------
trunk/NSObject_SKExtensions.m
Modified: trunk/NSObject_SKExtensions.m
===================================================================
--- trunk/NSObject_SKExtensions.m 2008-07-24 09:57:53 UTC (rev 4290)
+++ trunk/NSObject_SKExtensions.m 2008-07-24 10:45:49 UTC (rev 4291)
@@ -79,14 +79,7 @@
}
+ (void)exchangeMethodForSelector:(SEL)aSelector1
withMethodForSelector:(SEL)aSelector2 {
- Method method1 = class_getClassMethod(self, aSelector1);
- Method method2 = class_getClassMethod(self, aSelector2);
- if (method1 && method2) {
- Class metaClass = SK_object_getClass(self);
- IMP imp = SK_method_getImplementation(method2);
- imp = SK_class_replaceMethod(metaClass, aSelector1, imp,
SK_method_getTypeEncoding(method1));
- SK_class_replaceMethod(metaClass, aSelector2, imp,
SK_method_getTypeEncoding(method2));
- }
+ [self setMethod:[self setMethodFromSelector:aSelector2
forSelector:aSelector1] typeEncoding:NULL forSelector:aSelector2];
}
- (void)exchangeMethodForSelector:(SEL)aSelector1
withMethodForSelector:(SEL)aSelector2 {
@@ -94,13 +87,7 @@
}
+ (void)exchangeInstanceMethodForSelector:(SEL)aSelector1
withInstanceMethodForSelector:(SEL)aSelector2 {
- Method method1 = class_getInstanceMethod(self, aSelector1);
- Method method2 = class_getInstanceMethod(self, aSelector2);
- if (method1 && method2) {
- IMP imp = SK_method_getImplementation(method2);
- imp = SK_class_replaceMethod(self, aSelector1, imp,
SK_method_getTypeEncoding(method1));
- SK_class_replaceMethod(self, aSelector2, imp,
SK_method_getTypeEncoding(method2));
- }
+ [self setInstanceMethod:[self setInstanceMethodFromSelector:aSelector2
forSelector:aSelector1] typeEncoding:NULL forSelector:aSelector2];
}
@end
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit