Hi

I simply want to delete the actual database (SQL Database) and load a new one.

First: all controllers which hold refs to NSManagedObjects will be deleted. Then the i call [[NSGarbageCollector defaultCollector] collectExhaustively];
Then i disconnect from the database.

This is the code to disconnect from the databse:

-(BOOL) removeData {
         NSError *error;
        
        if (managedObjectContext != nil) {
        if ([managedObjectContext commitEditing]) {
                        if ([managedObjectContext persistentStoreCoordinator]
&& [[[managedObjectContext persistentStoreCoordinator] persistentStores] count] > 0) { if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) {
                                        NSLog(@"Save Error.");
                                }
                        }
                }
        }
        
        managedObjectContext = nil;
        persistentStoreCoordinator = nil;
        managedObjectModel = nil;
        
        return YES;
}


The problem is that the disconnect and the collection of garbage is parallel. So the invalidate exception is thrown.

I have no problems with the disconnect from the old and the reconnect to new databse. Thats working. Only the old NSManagedObjects seems to be not deleted and create errors.



Am 12.02.2009 um 16:30 schrieb I. Savant:

On Thu, Feb 12, 2009 at 9:52 AM, Samuel Strupp <str...@synium.de> wrote:

i have problem with the garbage collector. May App is a CoreData App (not
document based). If i try to change the database and load a new one.

It's not clear what you mean here. Be *very* specific (and show code).

--
I.S.

_______________________________________________

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

Reply via email to