最後一次更新XCode後,它建議我將代碼更新爲swift 3語言。 XCode幫助我進行了更新,在我修復了一些需要手動更新的內容之後,我遇到了一個轉換,我無法弄清楚該怎麼做。Restkit和快速刪除孤立對象3
這是關於刪除Restkit中的孤立對象。下面是雨燕2至SWIFT 3更新的生成的代碼通過的XCode:更新代碼與
/Users/mast/work/gColegios/iOSapp/gColegios/AppDelegate.swift:417:34: Cannot convert value of type '(URL!) -> <<error type>>' to expected argument type '((URL?) -> NSFetchRequest<NSFetchRequestResult>?)!'
所以我有:
// fetchRequestBlock to delete orphaned objects ------ tmenus --------
manager?.addFetchRequest { (url:URL!) -> NSFetchRequest<AnyObject>! in
let pathMatcher = RKPathMatcher(pattern: config.getDataPath)
let match = pathMatcher.matchesPath(url.relativePath, tokenizeQueryStrings: false, parsedArguments: nil)
guard match else {
return nil
}
let fetchRequest = NSFetchRequest(entityName: "TipoMenuEntity")
return fetchRequest
}
而且錯誤它顯示快速管理請求的新方法3:
// fetchRequestBlock to delete orphaned objects ------ tmenus --------
manager?.addFetchRequest { (url:URL!) -> NSFetchRequest<TipoMenu>! in
let pathMatcher = RKPathMatcher(pattern: config.getDataPath)
let match = pathMatcher.matchesPath(url.relativePath, tokenizeQueryStrings: false, parsedArguments: nil)
guard match else {
return nil
}
let fetchRequest: NSFetchRequest<TipoMenu> = TipoMenu.fetchRequest()
return fetchRequest
}
現在它顯示了新的錯誤:
/Users/mast/work/gColegios/iOSapp/gColegios/AppDelegate.swift:418:34: Cannot convert value of type '(URL!) -> NSFetchRequest<TipoMenu>!' to expected argument type '((URL?) -> NSFetchRequest<NSFetchRequestResult>?)!'
我已經嘗試了一切: '!(!URL) - > NSFetchRequest' 改變'((URL?) - > NSFetchRequest?)!' ,以及各種組合之間?和!
任何人都可以幫我解決這個問題嗎?
在此先感謝
參數和返回值都應該是可選的 – Wain