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:41:26 -0800
On Feb 9, 2007, at 10:34 PM, I. Savant wrote:
From your description, it doesn't sound like it should require
anything more than a standard master/detail bindings setup. If you
haven't already, I suggest taking a long, hard look at the master/
detail bindings examples and adapting them to your own model.
Well, maybe we're looking at different examples. :)
I modified Malcom's ToDos example to fiddle with the idea I had, and
it seems to be working fine.
Creating an object is simple:
- (IBAction)testMyOwnAdd:(id)sender;
{
NSMutableDictionary * dict = [NSMutableDictionary dictionary];
[dict setObject:@"bananas" forKey:@"what"];
[controller addObject:dict];
}
And for doing whatever manipulation I need behind the scenes, I do
just implement methods named a certain way. With the array controller
bound to the "toDos" array, you need to implement:
- (NSArray *)toDos;
- (void)setToDos:(NSMutableArray *)aToDos;
- (unsigned int)countOfToDos;
- (id)objectInToDosAtIndex:(unsigned int)index;
- (void)insertObject:(id)anObject inToDosAtIndex:(unsigned int)index;
- (void)removeObjectFromToDosAtIndex:(unsigned int)index;
- (void)replaceObjectInToDosAtIndex:(unsigned int)index withObject:
(id)anObject;
This lets you give the controller a mutable array (so it's not
changing the array directly which is what I was trying to avoid) but
still have the whole thing be editable.
So in a nutshell, I figured this out.
WARNING: It's 1:30 AM locally and I may be missing something
obvious. Take this with a whole bag of salt, not just a grain.
:)
I appreciate the help.
Here's another possibly silly question:
3) Currently I have multiple popups with a bunch of items with just a
title (no tag). There's also a "None" item at the top, and a
separator below it. In my glue code, I select the item with a given
title. For example: [popup selecteItemWithTitle:[fileType
blahAtIndex:i]]
What's the right way to do this with a binding? It seems I'd want to
do something like bind the popup's selectedValue to
arrayController.selection.blahAtIndex???
I think there must a better way all around to handle this.
--
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