Deleting all objects from Core Data store

  • Hi everyone,

    Part of my CoreData application requires to delete all objects of a
    specific set. I am able to find objects using a Predicate and delete a
    singular object. How do I go about deleting all objects from a set?

    Thanks a lot.

    --
    "I never look back darling, it distracts from the now", Edna Mode (The
    Incredibles)
  • > Part of my CoreData application requires to delete all objects of a
    > specific set. I am able to find objects using a Predicate and delete a
    > singular object. How do I go about deleting all objects from a set?

    Using a for statement ? There's no "DELETE FROM", because Core Data isn't a relational database.

    If you have a lot of objects to delete in the set, refactor your model to add a object to hold the set (with a cascade rule) and when required, delete it.

    :: marcelo.alves
  • Hi Marcelo,

    Yeah for statement is definately something I can live with since its a
    small data set. What predicate should I use to create a set of all the
    objects?

    On Jan 14, 2008 9:35 PM,  <marcelo.alves...> wrote:
    >> Part of my CoreData application requires to delete all objects of a
    >> specific set. I am able to find objects using a Predicate and delete a
    >> singular object. How do I go about deleting all objects from a set?
    >
    > Using a for statement ? There's no "DELETE FROM", because Core Data isn't a relational database.
    >
    > If you have a lot of objects to delete in the set, refactor your model to add a object to hold the set (with a cascade rule) and when required, delete it.
    >
    >
    > :: marcelo.alves
    >

    --
    "I never look back darling, it distracts from the now", Edna Mode (The
    Incredibles)
previous month january 2008 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Go to today