Re: Patching implementation in +load. Was: …Mapping Model : Spurious Warning
Re: Patching implementation in +load. Was: …Mapping Model : Spurious Warning
- Subject: Re: Patching implementation in +load. Was: …Mapping Model : Spurious Warning
- From: Kyle Sluder <email@hidden>
- Date: Tue, 7 Sep 2010 16:06:58 -0700
On Tue, Sep 7, 2010 at 3:55 PM, Kyle Sluder <email@hidden> wrote:
> Since all you're doing is adding methods, +load might be an okay time
> to do things, except if the method you're replacing comes from a
> category. You might want to defer to +initialize instead.
For the record, this is still risky business. As bbum's article says,
a category's +initialize implementation replaces the class's. Though
it's a bad idea to implement +initialize in a category, and certainly
a bug to implement it in more than one category or in both a category
and the main implementation, since Core Data is a black box it's quite
possible that the Core Data developers trust themselves enough to
implement critical methods like +initialize in internal categories.
At Omni, we use a custom +initialize-esque method called +didLoad that
was originally written to avoid bugs in NeXTSTEP. It relies on the
application invoking OBPostLoader sometime early in the application's
life—just as Apple's article advises you to do with this method swap.
OBPostLoader is part of the OmniBase framework, found here on github:
http://github.com/omnigroup/OmniGroup/tree/master/Frameworks/OmniBase/
As always, please read the license before using the Omni Frameworks
source code. (Don't worry, it's not long.)
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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