--- NSObject+Extensions.m.orig 2003-12-15 15:17:28.000000000 +1100 +++ NSObject+Extensions.m 2012-04-02 10:04:35.000000000 +1000 @@ -89,22 +89,23 @@ IMP EDGetFirstUnusedIMPForSelector(Class { #ifndef GNU_RUNTIME IMP activeIMP; - struct objc_method_list *mlist; void *iterator; int i; - + Method *methlist; + int count; + if(isClassMethod) aClass = aClass->isa; iterator = 0; activeIMP = [aClass instanceMethodForSelector:aSelector]; - while((mlist = class_nextMethodList(aClass, &iterator)) != NULL) - { - for(i = 0; i < mlist->method_count; i++) - { - if((mlist->method_list[i].method_name == aSelector) && (mlist->method_list[i].method_imp != activeIMP)) - return mlist->method_list[i].method_imp; - } - } + methlist = class_copyMethodList(aClass, &count); + for (i = 0; i < count; i++) { + if((method_getName(methlist[i]) == aSelector) && (method_getImplementation(methlist[i]) != activeIMP)) { + IMP unused = method_getImplementation(methlist[i]); + free(methlist); + } + } + free(methlist); return NULL; #else /* GNU_RUNTIME */ #warning ** implementation missing for GNU runtime