core-dataensembles

Setting up CDEPersistentStoreEnsemble gives [NSMapTable cde_strongToStrongObjectsMapTable]:


I am setting up ensembles to sync CoreData to iCloud. But it crashes on launch: [NSMapTable cde_strongToStrongObjectsMapTable]: unrecognized selector sent to class 0x10d978c70 2016-08-05 12:48:42.502 Shooters_Journal[30266:751831] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSMapTable cde_strongToStrongObjectsMapTable]: unrecognized selector sent to class 0x10d978c70'

I dont understand what this means. How do I proceed to debug?? I have added my CoreData Stack and Ensembles setup. For the record, the app works very well without setting up ensembles. In my AppDelegate I have:

 func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// setups


// Setup Ensemble

        let modelURL = NSBundle.mainBundle().URLForResource("Myidentifier", withExtension: "momd")
        cloudFileSystem = CDEICloudFileSystem(ubiquityContainerIdentifier: nil)
        let storeURL = self.applicationDocumentsDirectory.URLByAppendingPathComponent("CoreData.sqlite")

        ensemble = CDEPersistentStoreEnsemble(ensembleIdentifier: "ShotsStore", persistentStoreURL: storeURL, managedObjectModelURL: modelURL!, cloudFileSystem: cloudFileSystem)
        ensemble.delegate = self

 return true
    }

My CoreData stack is the default XCode creates

// MARK: - Core Data stack

    lazy var applicationDocumentsDirectory: NSURL = {

        let urls = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask)
        return urls[urls.count-1]
    }()

    lazy var managedObjectModel: NSManagedObjectModel = {

       let modelURL = NSBundle.mainBundle().URLForResource("Myidentifier", withExtension: "momd")

        return NSManagedObjectModel(contentsOfURL: modelURL!)!

    }()

    lazy var persistentStoreCoordinator: NSPersistentStoreCoordinator = {

        // Create the coordinator and store
        let coordinator = NSPersistentStoreCoordinator(managedObjectModel: self.managedObjectModel)
        let storeUrl = self.applicationDocumentsDirectory.URLByAppendingPathComponent("SingleViewCoreData.sqlite")
        var failureReason = "There was an error creating or loading the application's saved data."



        do {
            try coordinator.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: storeUrl, options: nil)

        } catch {
            // Report any error we got.
            var dict = [String: AnyObject]()
            dict[NSLocalizedDescriptionKey] = "Failed to initialize the application's saved data"
            dict[NSLocalizedFailureReasonErrorKey] = failureReason

            dict[NSUnderlyingErrorKey] = error as NSError
            let wrappedError = NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict)

            NSLog("Unresolved error \(wrappedError), \(wrappedError.userInfo)")
            abort()
        }

        return coordinator
    }()

    lazy var managedObjectContext: NSManagedObjectContext = {

        let coordinator = self.persistentStoreCoordinator
        var managedObjectContext = NSManagedObjectContext(concurrencyType: .MainQueueConcurrencyType)
        managedObjectContext.persistentStoreCoordinator = coordinator
        return managedObjectContext
    }()

The app compiles fine, but on start I get following error:

[NSMapTable cde_strongToStrongObjectsMapTable]: unrecognized selector sent to class 0x10d978c70

All I now is that the line:

ensemble = CDEPersistentStoreEnsemble(ensembleIdentifier: "ShotsStore", persistentStoreURL: storeURL, managedObjectModelURL: modelURL!, cloudFileSystem: cloudFileSystem)

is causing the crash. I have no idea if its the persistentStoreURL, managedObjectModelURL or cloudFileSystem that is cousing the error.


Solution

  • I think you forgot the -ObjC step in the README. That will cause all categories to be linked, which is causing the missing symbols error.