@@ -245,14 +245,13 @@ objc_autoreleasePoolPop(pool); } #ifdef OF_HAVE_BLOCKS -- (OFNotificationCenterHandle *) - addObserverForName: (OFNotificationName)name - object: (id)object - usingBlock: (OFNotificationCenterBlock)block +- (id)addObserverForName: (OFNotificationName)name + object: (id)object + usingBlock: (OFNotificationCenterBlock)block { void *pool = objc_autoreleasePoolPush(); OFNotificationCenterHandle *handle = [[[OFNotificationCenterHandle alloc] initWithName: name object: object @@ -267,13 +266,20 @@ return [handle autorelease]; } #endif -- (void)removeObserver: (OFNotificationCenterHandle *)handle +- (void)removeObserver: (id)handle_ { - void *pool = objc_autoreleasePoolPush(); + OFNotificationCenterHandle *handle; + void *pool; + + if (![handle_ isKindOfClass: [OFNotificationCenterHandle class]]) + @throw [OFInvalidArgumentException exception]; + + handle = handle_; + pool = objc_autoreleasePoolPush(); /* {} required to avoid -Wmisleading-indentation false positive. */ if (![handle isKindOfClass: [OFNotificationCenterHandle class]]) { @throw [OFInvalidArgumentException exception]; }