Re: NSArrayController: delay in setting selection, inserting item?
Re: NSArrayController: delay in setting selection, inserting item?
- Subject: Re: NSArrayController: delay in setting selection, inserting item?
- From: mmalcolm crawford <email@hidden>
- Date: Sun, 26 Jun 2005 14:16:31 -0700
On Jun 26, 2005, at 1:08 PM, Joshua Scott Emmons wrote:
Do you want the completed attribute to be set for every new
MyEntity object, or is this a special case? If the former, then
you should override awakeFromInsert.
Ok, but what if I want to insert a value that can only be
determined by the state of the view at run time?
Then it's the latter case, and awakeFromInsert doesn't apply.
Let's say I have two buttons used to insert an entry, one called
"Add Yesterday" with a tag of 0, and one called "Add Today" with a
tag of 1.
There are a number of approaches; one would be to create a subclass
of NSArrayController and override insert: along the lines of (typed
in Mail):
- (void)insert:(id)sender
{
unsigned int = [self selectionIndex];
// assuming this is where you want the insert to go
id newObject = [self newObject];
// configure newObject based on sender's tag
[self insertObject: newObject atArrangedObjectIndex:
selectionIndex +1];
}
mmalc
_______________________________________________
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