Create initial folder structure

This commit is contained in:
Matthias Neeracher 2011-08-10 16:27:02 +02:00
parent 0916b50bf4
commit 328b497040

View File

@ -33,16 +33,6 @@
#pragma mark - #pragma mark -
#pragma mark MADocument #pragma mark MADocument
- (id)init
{
self = [super init];
if (self) {
// Add your subclass-specific initialization here.
// If an error occurs here, send a [self release] message and return nil.
}
return self;
}
/* /*
This is the name of the Core Data store file contained within the document package. This is the name of the Core Data store file contained within the document package.
You can change this whatever you want -- the user will not see this file. You can change this whatever you want -- the user will not see this file.
@ -51,6 +41,29 @@ static NSString *StoreFileName = @"MediannoDB.sql";
@implementation MADocument @implementation MADocument
- (id)initWithType:(NSString *)typeName error:(NSError **)outError
{
self = [super initWithType:typeName error:outError];
if (self) {
/*
* Start with a root folder and an inbox folder
*/
NSManagedObjectContext *moc = [self managedObjectContext];
[[moc undoManager] disableUndoRegistration];
MAFolder * rootFolder = [NSEntityDescription insertNewObjectForEntityForName:@"MAFolder"
inManagedObjectContext:moc];
[rootFolder setName:@""];
MAFolder * inboxFolder = [NSEntityDescription insertNewObjectForEntityForName:@"MAFolder"
inManagedObjectContext:moc];
[inboxFolder setName:@"Inbox"];
[inboxFolder setParent:rootFolder];
[moc processPendingChanges];
[[moc undoManager] enableUndoRegistration];
}
return self;
}
- (NSString *)windowNibName - (NSString *)windowNibName
{ {
// Override returning the nib file name of the document // Override returning the nib file name of the document