Re: Scenarios I don't know how to use Bindings in
Re: Scenarios I don't know how to use Bindings in
- Subject: Re: Scenarios I don't know how to use Bindings in
- From: Seth Willits <email@hidden>
- Date: Fri, 9 Feb 2007 22:05:22 -0800
On Feb 9, 2007, at 9:47 PM, I. Savant wrote:
Bind the button's enabled binding to the array controller's
canRemove controller key (with no model key path). This will
properly manage the state versus selection.
After half an hour of fiddling, giving up, and writing that email I
discovered the controller key "canRemove" a few minutes later.
Sheesh. :)
2) Currently I have a FileTypesManager object which manages an
array (and some other structures) of FileType objects. The glue
code in my preferences controller displays the file types in a
table view, and then allows them to be edited. Before adding a new
file type, I first display a sheet to get some critical values
from the user. When deleting, there's also a confirmation sheet.
So how can I do the same thing with bindings?
You might have to give more details here. The sheets should work
exactly the same ... you may be thinking that you have to connect a
button to the controller's add: action ... but nothing says you
can't connect your "Add" button to your own method (to display the
sheet, etc.) and send -add: to your array controller when you want
to. You can even call -addObject: and hand it a ready-made object.
If that's not the answer to the question you asked, maybe others
will understand where I didn't ... but it would still help to give
more details. :-)
Hmm... Okay let's try it again...
There's a FileTypesManager singleton object with (among others) these
methods:
- (NSArray *)fileTypes;
- (void)addFileType:(WBFileType *)fileType;
- (void)removeFileType:(WBFileType *)fileType;
In FileTypesPreferences glue code, I show the sheet, create an
object, set its values, call addFileType: on the singleton, then call
reloadData on the tableView.
In the bindings approach, I kinda did this a little funny. Since in
the nib there is no FileTypesManager object, I added a -fileTypes
method in FileTypesPreferences which calls FileTypesManager's
fileTypes method. I then set up an array controller to the -fileTypes
array in FileTypesPreferences. When adding an object I would show the
sheet, create the object, set its values, and ...... call addObject:
on the controller? Do I have to? I need to feed it through the same
code in addFileType because there are things I need to do when the
object needs to be added. Is saw one bindings example use a bunch of
methods, such as:
- (unsigned int)countOfFileTypes;
- (id)objectInFileTypesAtIndex:(unsigned int)index;
- (void)insertObject:(id)anObject inFileTypesAtIndex:(unsigned int)
index;
...
I'm going to guess that something like this is what I want? I'm not
entirely sure how that works.
Thanks,
--
Seth Willits
_______________________________________________
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