I’ve started a new side project called AspectObjectiveC on github. It’s a little aspect-oriented programming framework for objective-c.
In a nutshell, it allows you to run arbitrary code before, after, or instead of any method at runtime. You can modify arguments before they enter the method, modify the return value of the method, or completely replace the method’s implementation without touching the class’ source code. This includes classes that you don’t have the source code for (e.g. other frameworks). It’s released under the MIT license, even though it doesn’t mention it anywhere yet.
It’s still rough, but it’s working (on my machine
). If you want to try it out then build the framework target and whack it into an app as a private framework. It’s got no documentation yet, but the public headers only expose one protocol (AOCAdvice) and one class (AOCAspectManager) with two methods, so it’s pretty intuitive. You can check the unit tests for example usage too.
If you want to contribute code, that’d be great. If you want to test it out on platforms other than OSX >= 10.5, i386 with gcc, that would also be great. Feel free to shoot me an email about it.
If you enjoyed this post, why not subscribe?

This looks really slick, and I’ve added this to my “must watch” list.
I’ve delved into this a little bit myself with Cocoa and the NSCoding protocol. My code is posted here:
http://davedelong.com/blog/2009/04/13/aspect-oriented-programming-objective-c