Swift:尝试将记录推送到实体时 NSManaged 中出现 "Expected expression after operator" 错误

Swift: "Expected expression after operator" error in NSManaged while trying to push a record to entity

我有一个实体,其中有 4 个字符串属性。我正在尝试将记录推送到实体中,但我在记录行中遇到 'Expected Expression after operator' 错误。

   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)

这一行

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