【问题标题】:Issue after updating to Swift 3 [duplicate]更新到 Swift 3 后的问题 [重复]
【发布时间】:2016-11-20 07:08:47
【问题描述】:

我打开了我的一个项目,Xcode 要求我将源更新为Swift 3。单击保存后,我得到了预期的错误。创建fetchRequest 时发生错误。 (第 8 行有错误信息)

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

    let appDelegate = UIApplication.shared().delegate as! AppDelegate

    let managedContext = appDelegate.managedObjectContext!

    let fetchRequest = NSFetchRequest(entityName:"Sessions") //<- Error error message: generic parameter 'ResultType' could not be inferred

        do {
            sessions = try managedContext.fetch(fetchRequest) as! [Sessions]
        } catch let error as NSError {
            print("Could not fetch \(error), \(error.userInfo)")
        }

        print("fetched")

        self.tableView.reloadData()
    }
}

【问题讨论】:

    标签: ios swift core-data swift3


    【解决方案1】:

    我自己也找到了解决方案。我刚从

    let fetchRequest = NSFetchRequest(entityName:"Sessions")

    let fetchRequest: NSFetchRequest&lt;NSFetchRequestResult&gt; = NSFetchRequest(entityName:"Sessions")

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-17
    • 2016-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多