Re: NSPopupButton with NSArrayController
Re: NSPopupButton with NSArrayController
- Subject: Re: NSPopupButton with NSArrayController
- From: Ferhat Ayaz <email@hidden>
- Date: Sun, 7 Jan 2007 03:49:48 +0100
ok. I got it. addObject: was the keyword. Thanks a lot.
- (IBAction)makeInvoice:(id)sender
{
NSManagedObjectContext *moc = [invoiceArrayController
managedObjectContext];
NSEntityDescription *entity = [NSEntityDescription
entityForName:@"Invoice" inManagedObjectContext:moc];
NSString *className = [entity managedObjectClassName];
Class entityClass = NSClassFromString(className);
NSManagedObject *invoice = [[entityClass alloc]
initWithEntity:entity
insertIntoManagedObjectContext:moc];
[invoiceArrayController addObject:invoice];
NSLog(@"Invoice nr: %@",[invoice valueForKey:@"nr"]);
}
On Jan 7, 2007, at 2:42 AM, Andreas Mayer wrote:
Am 07.01.2007 um 01:04 Uhr schrieb Ferhat Ayaz:
I want to use the add: method of an NSArrayController.
Why?
This is very important.
Why?
Any AppKit tasks (refreshing TableViews etc.) are performed
"after" method -makeInvoice.
That's why you should create the object yourself and use -
addObject: instead of -add:
Anyway. *Assuming* -selectsInsertedObjects ist set to YES for your
controller, -selectedObjects will return an array containing your
newly created object after adding it. But I'm not sure if this
works before the next run through the run loop or only afterwards.
Again: To avoid this problem, just create the object yourself.
Andreas
_______________________________________________
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:
40googlemail.com
This email sent to email@hidden
_______________________________________________
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