无法转换输入类型的值nserror? (又称输入可选的nserror到期望的参数类型()

时间:2015-10-04 08:52:16

标签: ios swift error-handling exception-handling xcode7

我现在更新我的Xcode我有Xcode 7,当它转换我的代码时我有这个NSError问题,知道如何修复它吗?

    if let managedObjectContext = (UIApplication.sharedApplication().delegate as? AppDelegate)?.managedObjectContext {



        restaurant = NSEntityDescription.insertNewObjectForEntityForName("Restaurant", inManagedObjectContext: managedObjectContext) as! Restaurant
        restaurant.name = nameTextField.text
        restaurant.type = typeTextFiedl.text
        restaurant.location = locationTextField.text
        restaurant.image = UIImagePNGRepresentation(imageView.image!)
        restaurant.isVisited = isVisted
        //restaurant.isVisited = NSNumber.convertFromBooleanLiteral(isVisited)

        var e: NSError?
        if managedObjectContext.save(&e) != true {
            print("insert error: \(e!.localizedDescription)")
            return
        }
    }

0 个答案:

没有答案
相关问题