Re: What is the best way to store some kind of identifying string in an interface builder object?
Re: What is the best way to store some kind of identifying string in an interface builder object?
- Subject: Re: What is the best way to store some kind of identifying string in an interface builder object?
- From: Erik Buck <email@hidden>
- Date: Thu, 18 Jun 2009 10:59:13 -0700 (PDT)
See the - (void)setRepresentedObject:(id)anObject method of NSCell. You can set a string or dictionary and the represented object and retrieve it via -representedObject.
You can also instantiate an array and add objects to the array within IB. Then you only need an outlet instance variable to reference the array and not separate instance variables for all of the user interface objects. See "Foundation Collections Palette" You can populate the array entirely within IB. Make any target/action connections in IB.
http://www.geocities.com/kritter_cocoadev/
For some final advice: Don't do what you are contemplating. Users hate interfaces that change outside the user's control. If a group of objects are going to appear or disappear, consider whether they should become enabled or disabled instead. If objects are logically associated, group the objects together visibly in boxes or matrix or tabs or through other means. Then you can enable or disable all elements of the box in code without needing to have outlets for every element. You can even hide or unhidden the whole box.
use
[[myBox subviews] makeObjectPerformSelector:@selector(setEnabled:) withObject:NO];
or similar.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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