I have a document-based CoreData app, which means there could be several docs open at once. I want to implement Export As CSV... (but not as a "supported file type," as this is one-way only). Being a Cocoa n00b, I'm struggling with where to put the action in a class that is current-document aware. I thought MyDocument.m (note the creative naming :) would make sense for toCSV(), but I can't hook a controller action up to the main menu in IB. The code:
- (IBAction) onExportToCSV:(id)sender { NSManagedObjectContext * moc = [self managedObjectContext]; NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"Event" inManagedObjectContext:moc]; NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease]; [request setEntity:entityDescription]; NSError *error; NSArray *result = [moc executeFetchRequest:request error:&error]; // File saving stuff goes here... } Questions: - Is the document class the right place? It makes sense to me that the document would know how to save itself - Would the controller, instead, want to tell the document to persist itself as CSV? - How can I hook a File > Export... menu item to a controller action. I can hook it to AppController and then send a message but it seems hacky. - [OT] This targets Snowy only. Do I really need to use release and autorelease if I turn on GC mandatory? Thanks_______________________________________________ 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