func updateClockWithTimeID(timeID:Int64){
let inMain:Bool = Thread.isMainThread
let fetchRequest:NSFetchRequest = LYClockModel!.fetchRequestFromTemplate(withName: "GetClockByTimeID", substitutionVariables: ["ID":timeID])!
fetchRequest.includesPropertyValues = true
fetchRequest.returnsObjectsAsFaults = false
var threadContext:NSManagedObjectContext? = nil
var mutableFetchResults:[Clock]
if inMain == false{
threadContext = NSManagedObjectContext.init(concurrencyType: .privateQueueConcurrencyType)
threadContext!.performAndWait({
threadContext!.parent = context
threadContext!.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy
})
do{
mutableFetchResults = try threadContext?.fetch(fetchRequest) as! [Clock]
}catch{
}
}else{
do{
mutableFetchResults = try context?.fetch(fetchRequest) as! [Clock]
}catch{
}
}
}
以上是我写的一段swift代码,但是
var mutableFetchResults:[Clock]
这一行总是报一个警告
Variable 'mutableFetchResults' was written to, but never read
尝试了一些方法,但是不知道如何消除比较好,请问该怎么做呢?
清除缓存就可以了...坑