Re: Problem when overriding new Apple methods with my categories, what is the best solution?
Re: Problem when overriding new Apple methods with my categories, what is the best solution?
- Subject: Re: Problem when overriding new Apple methods with my categories, what is the best solution?
- From: Erik Buck <email@hidden>
- Date: Fri, 15 Dec 2006 10:56:50 -0800 (PST)
Cocoa frameworks provide powerful versioning capabilities.
http://developer.apple.com/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/CreatingFrameworks.html
One solution is to use the versioning capability. You will have one framework package/bundle that contains both versions of the framework code so that one version can omit your un-needed categories.
An even better solution is to not use frameworks at all. If you only have 4 applications that use a framework, the virtues of having a shared framework at all are dubious. For an example of this reasoning, see http://wilshipley.com/blog/2005/11/frameworks-are-teh-suck-err.html
Finally, your idea to selectively load a bundle that contains your categories is feasible. It duplicates a lot of functionality provided by the built in versioning system, but you can do it. Just have some class in your framework check for the existence of a method via -respondsToSelector:, and if the method is not present, load the bundle containing the category that will add the method. You can do this on a class by class basis or with whatever granularity you want. An added bonus is that by loading you bundle last, your category's methods are sure to replace any other implementations even if the other implementations are also in a category. If you let the system do the loading, the final implementations are undefined. The last category loaded wins.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden