鍍金池/ 問(wèn)答/iOS/ 一個(gè)swift語(yǔ)法的問(wèn)題

一個(gè)swift語(yǔ)法的問(wèn)題

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{
                
            }
        }
        
    }

以上是我寫(xiě)的一段swift代碼,但是

var mutableFetchResults:[Clock]

這一行總是報(bào)一個(gè)警告

Variable 'mutableFetchResults' was written to, but never read

嘗試了一些方法,但是不知道如何消除比較好,請(qǐng)問(wèn)該怎么做呢?

回答
編輯回答
茍活

清除緩存就可以了...坑

2018年7月29日 15:23