small medium large xlarge

Back to: All Forums  Core Data
Generic-user-small
09 Jul 2010, 04:07
Mike Schroeder (3 posts)

I saw somewhere a suggestion to use NSManagedObjectID when loading up a fetch that is going to be used to iterate thru and delete objects. I have managed the code to load just the id but now how do I perform the delete? [mycontext deleteObject:obj]; wants a NSManagedObject and if I use [myContext objectWithID:myid]; it becomes self defeating as that will grab the whole object which is what I want to avoid.

Is there a way to do a delete from NSManagedObjectID without loading up the object?

Avatarsmall_pragsmall
09 Jul 2010, 21:49
Marcus S. Zarra (284 posts)

Never heard that one before. The answer is no, you need to load the object to delete it. However you don’t need to fully realize the object to delete it. Therefore the memory requirements are quite small.

The @NSManagedObjectID@ is normally used when you are passing references to @NSManagedObject@ instances between threads.

Generic-user-small
09 Jul 2010, 21:59
Mike Schroeder (3 posts)

Thank you sir - I can quit banging my head against the wall on this one now :-)

You must be logged in to comment