corestore

CoreStore refetch predicate NSFetchRequest issue

邮差的信 提交于 2020-01-25 09:34:07
问题 if I got it clear I need to refetch monitor when I search something: I have this function to refetch with provided string func search(searchText: String) { self.monitor.refetch(.where(format: "%K CONTAINS[cd] %@", #keyPath(ListEntityType.name), searchText), OrderBy<ListEntityType>(.ascending("name"))) } but this code is not compilable, only this below: func search(searchText: String) { self.monitor.refetch(Where<ListEntityType>("name", isEqualTo: searchText), OrderBy<ListEntityType>(

Swift generic func cannot convert value of type to expected argument type

≯℡__Kan透↙ 提交于 2019-12-11 14:58:28
问题 I try to create generic func func importArray<T: ImportableUniqueObject>(from exercisesDict: [[String: Any]], transaction: BaseDataTransaction) -> [T] { if let managedObject = try? transaction.fetchOne(From<T>()){ transaction.delete(managedObject) } let managedObjects = try! transaction.importUniqueObjects( Into<T>(), sourceArray: jsonObjects) return managedObjects } So first part works good: if let managedObject = try? transaction.fetchOne(From<T>()){ ,but second does not work: let