CoreStore icon indicating copy to clipboard operation
CoreStore copied to clipboard

Spotlight support

Open seanliu1 opened this issue 5 years ago • 1 comments

I recently work on coredata and spotlight integration https://developer.apple.com/videos/play/wwdc2017/210/

Apple introduces a few things NSCoreDataCoreSpotlightDelegate

container.persistentStoreDescriptions.forEach {
    $0.setOption(MyCoreDataCoreSpotlightDelegate(forStoreWith:$0, 
        model: container.managedObjectModel), 
        forKey:NSCoreDataCoreSpotlightExporter)
}

I wonder how to integrate spotlight and coredata using corestore.

I did not find any api exposed by corestore to allow me to do that, the closet thing I can find is storageOption in StorageInterface. However I set it , I will need to have both NSPersistentStoreDescription and NSManagedObjectModel

var storage = SQLiteStore(fileName: "contents.sqlite",
                    localStorageOptions: .allowSynchronousLightweightMigration
        )
        storage.storeOptions = [NSCoreDataCoreSpotlightExporter:MySpotLightDelegate(forStoreWith: <#T##NSPersistentStoreDescription#>, model: <#T##NSManagedObjectModel#>)]
         dataStack.addStorage(
            SQLiteStore(fileName: "contents.sqlite",
                        localStorageOptions: .allowSynchronousLightweightMigration)

not sure what should I put into storeOptions

seanliu1 avatar Mar 05 '20 06:03 seanliu1

The store must have persistent history tracking enabled to use NSCoreDataCoreSpotlightDelegate, but CoreStore have not. https://github.com/JohnEstropia/CoreStore/issues/295

spacedema avatar Sep 29 '21 13:09 spacedema