Both are options.
Dynamically adding methods, is via a C function called class_addMethod
. You can even change an existing method (and still use the original!), it's called method swizzling. You can read the Apple documentation, or google for other examples. Note that you will need something in the program to at least touch your library to get it loaded (if you put the swizzling in your class's +initialize
method), and it's probably easiest overall to just have the user initialize your library with something along the lines of [MYLibrary applicationLaunchedWithDelegate:self launchOptions:launchOptions]
.
If you know the class you need to add the method to, you can use a category.