【问题标题】:Swift: "Expected expression after operator" error in NSManaged while trying to push a record to entitySwift:尝试将记录推送到实体时,NSManaged 中出现“运算符后的预期表达式”错误
【发布时间】:2021-05-02 08:21:16
【问题描述】:

我有一个实体,其中有 4 个字符串属性。我正在尝试将记录推送到实体中,但在记录行中遇到“运算符后的预期表达式”错误。

   guard
        let appDelegate = UIApplication.shared.delegate as? AppDelegate
        else {
            return
    }
    let managedContext = appDelegate.persistentContainer.viewContext
    //2
    let entity = NSEntityDescription.entity(forEntityName: "Details", in: managedContext) !
    //3
    let record = NSManagedObject(entity: entity, insertInto: managedContext)

【问题讨论】:

    标签: swift core-data xcode8 nsmanagedobject


    【解决方案1】:

    这一行

    let entity = ....... "Details", in: managedContext)!   /// ! should be beside the line 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-06
      • 2018-12-24
      • 2016-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-25
      相关资源
      最近更新 更多