Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to delete all data (for example when user logs out) of core data? Not the models but data in the models #337

Closed
mabdullahsaeed opened this issue Jul 7, 2017 · 1 comment

Comments

@mabdullahsaeed
Copy link

Using SugarRecord with Swift 3. Is it possible to delete all data (for example when user logs out) of core data? Not the models/entities but data in the models/entities?

My SugarRecordManager.swift

  class SugarRecordManager
  {
  static let sharedInstance = SugarRecordManager()
   private init(){
    
   }

// Initializing CoreDataDefaultStorage
func coreDataStorage() -> CoreDataDefaultStorage {
    let store = CoreDataStore.named("db")
    let bundle = Bundle(for: type(of: self))
    let model = CoreDataObjectModel.merged([bundle])
    let defaultStorage = try! CoreDataDefaultStorage(store: store, model: model)
    return defaultStorage
}

// other functions for fetching and storing objects

// want to write a function here to wipe out all data
}
@pepicrft
Copy link

pepicrft commented Jul 7, 2017

Hey @mabdullahsaeed, it's possible to delete all the data calling the method removeStore() on your storage. Let me know if that helps.
https://github.com/carambalabs/SugarRecord/blob/master/SugarRecord/Source/CoreData/Storages/CoreDataDefaultStorage.swift#L104

@pepicrft pepicrft closed this as completed Jul 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants