• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CoreData - Fast Deletion Of Thousands Of ManagedObjects?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CoreData - Fast Deletion Of Thousands Of ManagedObjects?


  • Subject: Re: CoreData - Fast Deletion Of Thousands Of ManagedObjects?
  • From: email@hidden
  • Date: Tue, 20 Dec 2005 19:21:32 -0800

Might try to check the amount of relationships that need to deleted and nullified by the original delete.
It might be complex, in which case there is not much to do except hope for performance update or
maybe change your object model...

One thing, that *may* be slightly fast would be to call the raw C array and cycle through that like: (THIS IS UNTESTED!!)

///////////////////////////////

id undoManager = [[context undoManager] retain];

int numberOfObjectsToDelete = [objects count];
id arrayOfObjectsToDelete = [objects getObjects:&arrayOfObjectsToDelete];

int currentObject = 0;
while (currentObject =0; currentObject < objectsToDelete; currentObject ++)
{
[context deleteObject:objectsToDelete[currentObject] ];
}

[context setUndoManager:[undoManager autorelease]];

//////////////////////////////// Might give you 3 or 4 seconds faster... thats

Maybe the NSManagedContext should have a - (BOOL)deleteObjects: (NSArray *)objects method, that way
the context can analyze the relationships in relation to eachother and speed the delete....

Simon Liu wrote:

I have a tableview representing managed objects. If I select all the
managed objects e.g.10,000, and delete them from the
managedObjectContext, there is a long delay e.g. 30 seconds.

Is there a way to delete large numbers of objects from a context
quickly and avoid the spinning beach ball? I don't really want to
have to delete the objects in a background thread, or put up a panel
saying 'Deletion in progress'.

My managed objects have relationships with nullify and cascade
deletion rules. My deletion code looks something this:

id undoManager = [[context undoManager] retain];
[context setUndoManager:nil];

while (obj = [enumerator nextObject]) {
[context deleteObject:obj];
}

[context setUndoManager:[undoManager autorelease]];

Appreciate any tips. Thanks.
--Simon
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Follow-Ups:
    • Re: CoreData - Fast Deletion Of Thousands Of ManagedObjects?
      • From: mmalcolm crawford <email@hidden>
References: 
 >CoreData - Fast Deletion Of Thousands Of ManagedObjects? (From: Simon Liu <email@hidden>)

  • Prev by Date: Re: NSBox
  • Next by Date: Launch Services vs. NSWorkspace for app bundle path
  • Previous by thread: Re: CoreData - Fast Deletion Of Thousands Of ManagedObjects?
  • Next by thread: Re: CoreData - Fast Deletion Of Thousands Of ManagedObjects?
  • Index(es):
    • Date
    • Thread