I have an entity called “Orders”. What the best way to delete all of the orders? I know that I can query them and delete them one by one and then call save on the context, but is there a better, maybe more efficient proper way of doing this?
THnaks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Nope, that’s how you do it. Despite it usually using a database as a back-end data store, CoreData itself is not a database, it’s a relational object graph manager. As such, there’s no way to delete objects without actually fetching them and telling the context to delete them.