3lvis / DATAStack

100% Swift Simple Boilerplate Free Core Data Stack. NSPersistentContainer
Other
214 stars 44 forks source link

add new initializer: init(managedObjectModel : NSManagedObjectModel) #69

Closed OliverDobner-flinc closed 8 years ago

OliverDobner-flinc commented 8 years ago

I need a way to initialize DATAStack with a given ManagedObjectModel as the model is not in bundle I can access.

3lvis commented 8 years ago

Hi @OliverMahn-flinc

That should already be possible, just provide the bundle where the model is stored.

/**
 Initializes a DATAStack using the provided model name, bundle and storeType.
 - parameter modelName: The name of your Core Data model (xcdatamodeld).
 - parameter bundle: The bundle where your Core Data model is located, normally your Core Data model is in
 the main bundle but when using unit tests sometimes your Core Data model could be located where your tests
 are located.
 - parameter storeType: The store type to be used, you have .InMemory and .SQLite, the first one is memory
 based and doesn't save to disk, while the second one creates a .sqlite file and stores things there.
 */
public init(modelName: String, bundle: NSBundle, storeType: DATAStackStoreType) {
    self.modelName = modelName
    self.modelBundle = bundle
    self.storeType = storeType

    super.init()
}
OliverDobner-flinc commented 8 years ago

Hi, as I said, I can not access the model with a bundle. (Inside a private cocoa pod.) I tried various ways to access the model with bundle access and ended up implementing a method that returns the managed model. So the current initializer don't work for me.

3lvis commented 8 years ago

@OliverMahn-flinc Makes sense, I'll look into adding this method if possible. I'll update you if there are any issues with this :) Thanks for adding more info about it.

OliverDobner-flinc commented 8 years ago

Thanks for re-opening. 👍

3lvis commented 8 years ago

I know it's a long time since you requested this, but I hope it fixes the problem now.

OliverDobner-flinc commented 8 years ago

thanks!