Le 23 janv. 2010 à 21:43, cocoa-dev a écrit : > I have a core data app with a model where there is a one-to-many relationship > between CD and Track (CD has an NSSet called tracks). The tracks are shown > in an NSTableView and the content set is managed by an NSArrayController. To > manually add a track the user presses the add button which runs the "add:" > selector of the arrayController. Right now, to programmatically add a track > I do: > > [arrayController performSelector:@selector(add:) withObject:nil > afterDelay:0.0]; > Why just do not use [arrayController insertObject:newTrack atOffset:0]?
> Track *newTrack = [[Track alloc] init]; If Track is somehow a subclass of NSManagedObject, then it's not the right way to create it. You should use: NSEntityDescription * newTrackDesc = [NSEntityDescription entityForName:@"Track" inManagedObjectContext:moc]; Track * newTrack = [[Track alloc] initWithEntity:newTrackDesc insertIntoManagedObjectContext:moc]; where "moc" is a pointer to your managed object context. V. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com