Need Help with Bindings and Core Data...
Need Help with Bindings and Core Data...
- Subject: Need Help with Bindings and Core Data...
- From: Mike McCabe <email@hidden>
- Date: Fri, 28 Dec 2007 11:28:19 -0500
I have been trying to solve this problem for a while now but I guess I
just don't understand the bindings well enough to figure out what I'm
doing wrong...
I have a Core Data model that is bound to a main window which contains
details of the data. It uses the standard generated AppDelegate to
grab the data and setup the persistent store, the managed object
context and the the managed object model... If the file exists it
displays the data. If the file doesn't exist it gives me a blank
screen. That seems like the right actions...
Part of my process includes importing data from an old Access Database
and populating the CoreData Model. As part of this process I want to
remove the current store and basically load the old data migrate it to
a new file using CoreData and then go back to the main window and have
it display the new store.
So, the steps I take before doing the migration are as follows...
I release the managedObjectContext
I release the persistentStore
I delete the existing file...
I recreate the managedObjectContext which in turn reloads the
persistentStore
Unfortunately I get no data in the window... So I played around a bit
with creating an object on the Array Controller that is controlling
the screen inside Interface Builder. It works fine when it first
comes up but even after trying to re-initialize the binding to the new
managedObjectContext I still get no luck... Here is a portion of my
code...
url = [NSURL fileURLWithPath: [[coreDataDelegate
applicationSupportFolder] stringByAppendingPathComponent:
@"Namaste.sql"]];
if ( [fileManager fileExistsAtPath:[url path]] ) {
NSLog(@"Namaste.sql exists!\n");
/* Shutdown the current Core Data Set... */
[coreDataDelegate releasePersistentStore];
[fileManager removeItemAtPath:[url path] error:&error];
/* Restore the main Core Data Set... */
[coreDataDelegate managedObjectContext];
[coreDataDelegate restoreControllerBinding];
}
NSManagedObjectContext *moc = [coreDataDelegate managedObjectContext];
The releasePersistentStore is as follows...
-(void)releasePersistentStore {
[managedObjectContext release], managedObjectContext = nil;
[persistentStoreCoordinator release], persistentStoreCoordinator
= nil;
}
And the restoreControllerBinding is as follows...
-(void)restoreControllerBinding {
[clientArrayController bind:@"contentObject" toObject:self
withKeyPath:@"managedObjectContext" options:nil];
}
Any help would be appreciated... :)
Mike
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden