If not, you need to either: Have a shared reference to the same NSManagedObjectContext so that you delete the object from the same context that you created or fetched it from. If you're not using multiple threads, then you should only need to call NSManagedObjectContext alloc init once ever in your code or If you have to use two different instances of NSManagedObjectContext, then get the objectID from the NSManagedObject you got from the first context, so that you can later call: context deleteObject:context objectWithID:aObjectID The NSManagedObjectID is the same between contexts, but the NSManagedObject itself is not.
If not, you need to either: Have a shared reference to the same NSManagedObjectContext so that you delete the object from the same context that you created or fetched it from. If you're not using multiple threads, then you should only need to call NSManagedObjectContext alloc init once ever in your code. Or If you have to use two different instances of NSManagedObjectContext, then get the objectID from the NSManagedObject you got from the first context, so that you can later call: context deleteObject:context objectWithID:aObjectID; The NSManagedObjectID is the same between contexts, but the NSManagedObject itself is not.
I'm using the managedObjectContext ivar in the app delegate (put there by xcode when I created the project). The code that's causing the error references uses UIApplication sharedApplication delegate managedObjectContext. There's only that one instance used throughout the app.
– cetcet May 3 at 5:44 Just fixed it. It was a typo - nothing to do with the context. Sorry, and thanks for the help!
– cetcet May 3 at 6:07 For anyone else coming across this in a Google search, you MAY receive this error if you are passing an invalid object or other mistyped code to managedObjectContext deleteObject; I was passing an NSNumber* on accident and it was giving me this error instead of telling me I should be passing an NSManagedObject*. – Riley Dutton Oct 25 at 10:36.
I've enabled editing to allow the user to delete rows by swiping to the right. I get what the error says, but I can't see how it applies here. I use a retained reference to my context to create, fetch, and delete all objects from the database, so I'm sure there's only the one context.
I'm also not using multiple threads. Any idea what could be happening?
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.