Skip to content
This repository was archived by the owner on Dec 27, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Aspects.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ typedef NS_OPTIONS(NSUInteger, AspectOptions) {
usingBlock:(id)block
error:(NSError **)error;

+ (id<AspectToken>)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<AspectToken>)aspect_hookSelector:(SEL)selector
withOptions:(AspectOptions)options
Expand Down
8 changes: 8 additions & 0 deletions Aspects.m
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ @implementation NSObject (Aspects)
return aspect_add((id)self, selector, options, block, error);
}

+ (id<AspectToken>)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<AspectToken>)aspect_hookSelector:(SEL)selector
withOptions:(AspectOptions)options
Expand Down