Skip to content
An NSProxy based library for easily enabling AOP like functionality in Objective-C.
Objective-C Ruby Shell
Find file
Pull request Compare This branch is 14 commits ahead, 3 commits behind moszinet:origin.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
AOPProxy.xcodeproj
AOProxy
.coveralls.rb
.coveralls.sh
.gitignore
.travis.yml
AOPProxyDemo.m
AOPProxyTests.m
README.md

README.md

Coverage Status

Build Status

AOPProxy

An Aspect-Oriented proxy library written Objective-C (for iOS + OSX)

This library enables functionality similar to AOP or 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.

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 ( moszi@innoli.com ).

A simple example...

- (void) addInterceptor:   (NSInvocation*)i { NSLog(@"ADD intercepted.");        }

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

- (void) testAOP {

    NSMutableArray* testArray = [AOPProxy proxyWithClass:NSMutableArray.class];

    [(id)testArray interceptMethodStartForSelector:@selector(addObject:)
                             withInterceptorTarget:self
                               interceptorSelector:@selector( addInterceptor: )];

    [(id)testArray interceptMethodEndForSelector:@selector(removeObjectAtIndex:)
                           withInterceptorTarget:self
                             interceptorSelector:@selector( removeInterceptor: )];

    [testArray addObject:@(1)];
    [testArray removeObjectAtIndex:0];
}
Something went wrong with that request. Please try again.