Skip to content


Subversion checkout URL

You can clone with
Download ZIP
An NSProxy based library for easily enabling AOP like functionality in Objective-C.
Latest commit fb5dbee @moszinet Merge pull request #5 from mralexgray/modern
complete project refactor


#AOP in Objective-C

This library enables functionality similar to AOP (Aspect Oriented Programming) for Objective-C. 
Proxy classes can be created (by wrapping the original instances in an instance of AOPProxy) that
enable intercepting the beginning and the end of method invocations.
It also provides two other classes AOPMethodLogger and AOPThreadInvoker - AOPMethodLogger will log
automatically all method invocations for an object, and AOPThreadInvoker will make sure that no
matter what thread is used to invoke the methods on your object they will always be executed on
a specified thread.

If you use this library I would be happy to hear about it :) – so please drop a mail to Szilveszter Molnar ( ).

For a simple example check this:
- (void) addInterceptor:(NSInvocation *) i {
    NSLog(@"ADD intercepted.");

- (void) removeInterceptor:(NSInvocation *) i {
    NSLog(@"REMOVE END intercepted !");

- (void) testAOP {
    NSMutableArray* testArray = [[AOPProxy alloc] initWithNewInstanceOfClass:[NSMutableArray class]];
    [(AOPProxy*)testArray interceptMethodStartForSelector:@selector(addObject:)
                                      interceptorSelector:@selector( addInterceptor: )];
    [(AOPProxy*)testArray interceptMethodEndForSelector:@selector(removeObjectAtIndex:)
                                    interceptorSelector:@selector( removeInterceptor: )];
    [testArray addObject:[NSNumber numberWithInt:1]];
    [testArray removeObjectAtIndex:0];
    [testArray release];
Something went wrong with that request. Please try again.