Re: why don't custom views have a "tag" in IB?
Re: why don't custom views have a "tag" in IB?
- Subject: Re: why don't custom views have a "tag" in IB?
- From: James Bucanek <email@hidden>
- Date: Tue, 21 Nov 2006 13:39:21 -0700
Matt Neuburg wrote on Tuesday, November 21, 2006:
>On Tue, 21 Nov 2006 20:22:24 +0100, j o a r <email@hidden> said:
>>
>>On 21 nov 2006, at 20.10, Matt Neuburg wrote:
>>
>>> Why doesn't the Attributes inspector for a custom view in IB have a
>>> "tag"
>>> field? A custom view is a view, so it can have a tag - right? And why
>>> wouldn't I want to set that tag in IB?
As others have pointed out, Tag is not a settable property in NSView. It is up to a subclass to either define it as a constant or provide some means of settings it. NSControl implements a setTag: which is why all descendants of NSControl have settable tags in IB.
>>While NSView have a -tag method, it's actually only with NSControl
>>(and descendants) that you find both -tag and -setTag:, so I'm not
>>surprised that it's "missing" in IB.
>>
>>> If I can't set a tag, it's hard to tell one custom view from another.
>>>
>>> The difficulty is compounded by the fact that a custom view cannot
>>> have outlets.
>>
>>If you set it to be of a custom subclass (using the inspector) that
>>have outlets, I'm pretty sure that it would work.
>
>I'm pretty sure that it doesn't, so please actually try it in your copy of
>IB and tell me what you see.
It most certainly does. You need to define a custom subclass of NSView (MyView.h/MyView.m), then import that class definition (MyView.h) into IB. Create a custom NSView object, then set its custom class to the class of your NSView subclass and ... voila! ... all of the outlets and actions in your custom subclass are now available for binding in IB.
James Bucanek
____________________________________________________________________
Author of Beginning Xcode ISBN: 047175479X
<http://www.beginningxcode.com/>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden