Re: Problem accessing category method with bindings
Re: Problem accessing category method with bindings
- Subject: Re: Problem accessing category method with bindings
- From: Guy English <email@hidden>
- Date: Sun, 6 May 2007 17:36:12 -0400
Hmm, ugly. Turns out ABPerson overrides valueForKeyPath so that it
can expose the record properties as keys. That seems to short out
looking for your category methods during key look up time though. I
got it working by making an ABPerson subclass or, a better idea if
you're doing a larger project - make your own person class that has
an ABPerson as a member rather than subclassing it. That said to get
your code working like you want try the code below which implements
it's own key path lookup. Then, as early as possible in your app,
call: [[MyPerson class] poseAsClass: [ABPerson class]];
@interface MyPerson : ABPerson
@end
@implementation MyPerson
- (id) valueForKeyPath: (NSString*) keyPath
{
NSArray *path = [keyPath componentsSeparatedByString: @"."];
unsigned i, max;
max = [path count];
id value = self;
for ( i = 0; i < max; i++ )
{
value = [value valueForKey: [path objectAtIndex: i]];
}
return value;
}
@end
On 6-May-07, at 12:47 PM, Nicolas Seriot wrote:
Hello,
I have two categories: one on NSString, and one on ABPerson.
In IB, I want to use bindings to access my categories methods.
I can successfully access the new methods on NSString, but I can't
manage to access the ones on ABPerson.
I made a minimal project demonstrating my problem :
http://seriot.ch/temp/BindingCategoryProblem.png
http://seriot.ch/temp/BindingCategory.zip
Can anyone help me ?
Thank you in advance.
--
Nicolas Seriot
_______________________________________________
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:
40gmail.com
This email sent to email@hidden
_______________________________________________
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