Index: src/OFExceptions.m ================================================================== --- src/OFExceptions.m +++ src/OFExceptions.m @@ -422,12 +422,11 @@ { self = [super initWithClass: class__]; req_size = size; - /* FIXME: We need something that works for subclasses as well */ - if (class__ == [OFTCPSocket class]) + if ([class__ isSubclassOfClass: [OFTCPSocket class]]) err = GET_SOCK_ERR; else err = GET_ERR; return self; Index: src/OFObject.h ================================================================== --- src/OFObject.h +++ src/OFObject.h @@ -76,10 +76,17 @@ /** * \return The name of the class as a C string */ + (const char*)className; +/** + * \param class_ The class which is checked for being a superclass + * \return A boolean whether the class class is a subclass of the specified + * class + */ ++ (BOOL)isSubclassOfClass: (Class)class_; + /** * Checks whether instances of the class respond to a given selector. * * \param selector The selector which should be checked for respondance * \return A boolean whether instances of the class respond to the specified Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -99,10 +99,25 @@ return class_getName(self); #else return class_get_class_name(self); #endif } + ++ (BOOL)isSubclassOfClass: (Class)class +{ + Class iter; + +#ifdef OF_APPLE_RUNTIME + for (iter = self; iter != Nil; iter = class_getSuperclass(iter)) +#else + for (iter = self; iter != Nil; iter = class_get_super_class(iter)) +#endif + if (iter == class) + return YES; + + return NO; +} + (BOOL)instancesRespondToSelector: (SEL)selector { #ifdef OF_APPLE_RUNTIME return class_respondsToSelector(self, selector);