Re: Easier way to call NSBrowser's delegate from browser matrix?
Re: Easier way to call NSBrowser's delegate from browser matrix?
- Subject: Re: Easier way to call NSBrowser's delegate from browser matrix?
- From: Jeremy Dronfield <email@hidden>
- Date: Sun, 5 Dec 2004 19:28:58 +0000
That's much more sensible. I'll do that. Thanks.
Regards,
Jeremy
On 5 Dec 2004, at 5:26 pm, Nick Zitzmann wrote:
On Dec 5, 2004, at 5:14 AM, Jeremy Dronfield wrote:
- (id)browserDelegate
{
return [(NSBrowser *)[[[[[[self superview] superview] superview]
superview] superview] superview] delegate];
}
which seems somewhat ludicrous. There must be a smarter way?
Yes. What I usually do is add a category to NSView that returns the
first superview that is of a certain class, like this: (warning -
written in Mail, untested, you know the rest)
- (id)firstSuperviewOfClass:(Class)aClass
{
id aSuperview = [self superview];
while (aSuperview != nil)
{
if ([aSuperview isMemberOfClass:aClass])
{
break;
}
aSuperview = [aSuperview superview];
}
return aSuperview;
}
Then you can pass in the browser's class and message the browser that
way...
Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden