Hook for Objective C class' category initialization?

461 views
Skip to first unread message

Eimantas Vaičiūnas

unread,
Sep 25, 2010, 8:15:05 AM9/25/10
to cocoa-...@googlegroups.com
Dear List,

I'm creating a category for enumerable types of cocoa frameworks (like
NSArray, NSSet and NSDictionary). I was wondering if there are any
methods that are called when category is being "included" for the
object (loaded into memory?). Something like + (void)initialize?

All the best,
// E.

Jim Dovey

unread,
Sep 25, 2010, 8:27:34 AM9/25/10
to cocoa-...@googlegroups.com
+load is called when categories are loaded into memory, but there's no
+initialize when they're first used I'm afraid.

Sent from my iPhone

Eimantas Vaičiūnas

unread,
Sep 25, 2010, 8:37:20 AM9/25/10
to cocoa-...@googlegroups.com
On Sat, Sep 25, 2010 at 3:27 PM, Jim Dovey <jimd...@gmail.com> wrote:
> +load is called when categories are loaded into memory, but there's no
> +initialize when they're first used I'm afraid.
Thanks for such a quick response, Jim!

Kevin Ballard

unread,
Sep 27, 2010, 3:56:26 PM9/27/10
to cocoa-...@googlegroups.com
Note that +load is special. Unlike any other method, a +load in a category will not override +load in the original class. Both will get called.
--
Kevin Ballard
http://kevin.sb.org
kbal...@gmail.com
Reply all
Reply to author
Forward
0 new messages