ฉันกำลังอัปเกรดโค้ดที่มีอยู่เป็น Swift 2 และต้องการความช่วยเหลือในการบันทึกไฟล์ Plist
รหัสนี้ทำงานใน Xcode 6.3 แต่ตอนนี้ด้วย Xcode 7 และ Swift 2 มันแสดงข้อผิดพลาดนี้ให้ฉัน:
ไม่สามารถแปลงค่าของเวลา 'Int' เป็นประเภทอาร์กิวเมนต์ที่คาดหวัง 'NSPropertyListReadOptions' (หรือที่เรียกว่า 'NSPropertyListMutabilityOptions')
var resultValue = "Value goes here"
@IBAction func saveNote(sender: AnyObject) {
// Save note to plist
var appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
var pathForThePlistFile = appDelegate.plistPathInDocument
// Extract the content of the file as NSData
var data:NSData = NSFileManager.defaultManager().contentsAtPath(pathForThePlistFile)!
// Convert the NSData to mutable array
var notesArray = (try! NSPropertyListSerialization.propertyListWithData(data, options: Int(NSPropertyListMutabilityOptions.MutableContainersAndLeaves.rawValue), format: nil)) as! NSMutableArray
//
notesArray.addObject(resultValue)
// Save to plist
notesArray.writeToFile(pathForThePlistFile, atomically: true)
}
กรุณาช่วย!