diff --git a/Aspects.h b/Aspects.h index 5508f86..3203f6f 100644 --- a/Aspects.h +++ b/Aspects.h @@ -59,6 +59,11 @@ typedef NS_OPTIONS(NSUInteger, AspectOptions) { usingBlock:(id)block error:(NSError **)error; ++ (id)aspect_hookClassSelector:(SEL)selector + withOptions:(AspectOptions)options + usingBlock:(id)block + error:(NSError **)error; + /// Adds a block of code before/instead/after the current `selector` for a specific instance. - (id)aspect_hookSelector:(SEL)selector withOptions:(AspectOptions)options diff --git a/Aspects.m b/Aspects.m index c907066..e2ec425 100644 --- a/Aspects.m +++ b/Aspects.m @@ -103,6 +103,14 @@ @implementation NSObject (Aspects) return aspect_add((id)self, selector, options, block, error); } ++ (id)aspect_hookClassSelector:(SEL)selector + withOptions:(AspectOptions)options + usingBlock:(id)block + error:(NSError **)error { + Class cls = object_getClass(self.class); + return [cls aspect_hookSelector:selector withOptions:options usingBlock:block error:error]; +} + /// @return A token which allows to later deregister the aspect. - (id)aspect_hookSelector:(SEL)selector withOptions:(AspectOptions)options