title: How do I delete all objects from my persistent store in Core Data?
body: <p>I have Core Data working in my app.  So, I fetch an XML file, parse the data into model objects and insert them into core data.  They are saved in the persistent store and I can access them when I relaunch the app.  However, I want to be able to refresh the data in the persistent store at will, so I need to first remove existing objects from the store.  Is there a straight-forward method for this?</p>
  
  <p>Thanks</p>
  
  <hr>
  
  <p>I found this solution:  </p>
  
  <pre><code>[managedObjectContext lock];
  [managedObjectContext reset];//to drop pending changes
  if ([persistentStoreCoordinator removePersistentStore:persistentStore error:&amp;error])
  {
  NSURL* storeURL = [NSURL fileURLWithPath:[self pathForPersistentStore]];
  [[NSFileManager defaultManager] removeFileAtPath:[storeURL path] handler:nil];
  [self addPersistentStore];//recreates the persistent store
  }
  [managedObjectContext unlock];
  </code></pre>