[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RFC: [GDL2/base] unableToSetNullForKey: / unableToSetNilForKey:

From: David Ayers
Subject: Re: RFC: [GDL2/base] unableToSetNullForKey: / unableToSetNilForKey:
Date: Mon, 24 Mar 2003 16:45:00 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3b) Gecko/20030210

Richard Frith-Macdonald wrote:

On Monday, March 24, 2003, at 12:12 pm, David Ayers wrote:

How can we invoke unableToSetNullForKey: on OS X if unableToSetNilForKey: of NSObject is invoked?

You could create a class (called NilToNull for instance) which implements unableToSetNilForKey: by calling unableToSetNullForKey:, and use a call to GSObjCAddClassBehavior([NSObject class], [NilToNul class]) to add that method to NSObject.

Of course, you would have to be careful to make this call *after* loading any bundles which might contain categories containing the method.

Thanks Richard,

It took me a while to figure out why it wasn't working... and then to realize that this is tough to solve...

GSObjCAddMethods (Class class, struct objc_method_list *methods)
/* As long as the method isn't defined in the CLASS,
put the BEHAVIOR method in there. Thus, behavior
methods override the superclasses' methods. */
This is to insure that the behavior mechanism doesn't override explicitly implemented methods and this makes sense for most uses of behavior. Should/could we implement something like GSObjCReplaceMethod(Class class, struct objc_method *old, struct objc_method *new) or should this be handled differently?

And even if we can get it to work, I'm not so worried about other bundles with the category (for me there is base/Foundation and EOControl of GDL2. Anyone else trying to override this, has to worry about the ambiguities themselves.) but I'm more worried about actually having the initialzation code called in time before any KVC attempts are made. As I can't call the function in +load and these are categories on NSObject (i.e. I can't use +initialize on NSObject, and it wouldn't help adding it to all EOControl classes either, as they needn't be used before KVC is used :-(.

This is really tricky.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]