需要幫助的打擊代碼。剛剛更新到Xcode的7測試版不能援引「拯救」與類型的參數列表「(無)」
我得到以下錯誤「無法調用‘保存’有說法類型「(無)'」的列表。這是在IOS 6的工作
import UIKit
import CoreData
class ItemViewController: UIViewController {
@IBOutlet weak var textFieldDiveNumber: UITextField!
@IBOutlet weak var textFieldDiveDate: UITextField!
@IBOutlet weak var textFieldDiveLocation: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func saveTapped(sender: AnyObject) {
let appDel: AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
let contxt: NSManagedObjectContext = appDel.managedObjectContext
let en = NSEntityDescription.entityForName("List", inManagedObjectContext: contxt)
var newItem = Model(entity: (en)!, insertIntoManagedObjectContext: contxt)
newItem.divenumber = textFieldDiveNumber.text!
newItem.divedate = textFieldDiveDate.text!
newItem.divelocation = textFieldDiveLocation.text!
contxt.save(nil)
self.navigationController?.popToRootViewControllerAnimated(true)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
你有沒有試過'NULL'? – luk2302
是的,我有,它聲明NULL不可用,使用'nil'而不是這個導入的宏 – Scubadivingfool