Reputation: 29
I have one entity named Register
with several attributes. I want to delete all the data from the specific entity.
Please give me an answer related to iOS Swift.
Upvotes: 0
Views: 224
Reputation: 1959
I've also searched the same and found some like below. Using a Fetch Request to Collect all objects and delete one by one.
var arr: [AnyObject] = managedObjContextIns.executeFetchRequest(fetchReq, error: &error)
for managedObj: NSManagedObject in arr
{
managedObjContextIns.deleteObject(managedObj)
}
var error: NSErrorPointer? = nil
managedObjContextIns.save(&error)
Hope it helps.
Upvotes: 1