CocoaDev

Edit AllPages

Moved from FolderBasedDocuments… A (possible) method to have CoreData-based documents that are folders

I followed the above instructions to create an app that would open packaged documents, and then modified the MyDocument class so that the document has a managedObjectContext just like an NSPersistentDocument would. Let me know what you think. A bug that I’ve found is that it doesn’t show the black dot in the close button when there are unsaved changes. Other than that, it seems to work for me… Here’s the code:

// // MyDocument.h // CDDocTest // // Last updated by Jason Terhorst on 2/7/07. // Copyright Jason Terhorst 2007 . All rights reserved. //

#import <Cocoa/Cocoa.h>

@interface MyDocument : NSDocument { NSPersistentStoreCoordinator *persistentStoreCoordinator; NSManagedObjectModel *managedObjectModel; NSManagedObjectContext *managedObjectContext;

NSString * resourceFileName; }

@end

// MyDocument.m // CDDocTest // // Last updated by Jason Terhorst on 2/7/07. // Copyright Jason Terhorst 2007 . All rights reserved. //

#import “MyDocument.h”

@implementation MyDocument

}

@end

Could you perhaps post the complete project to make it easy to see what this does? I am interested in doing something like this in my application.