Ich verstehe, dass das NotificationCenter geändert hat, und ich habe nachgeschlagen, wie es zu der neuen Implementierung ändern, mit diesem Link: NotificationCenter issue on Swift 3, aber ich kann immer noch nicht meins zur Arbeit! Ich bin einen Auftrag aus meiner Klasse machen die Klasse Textbuch mit und das ist meine Klasse so weit:Verwenden Sie NotificationCenter, um Observer in swift 3 hinzuzufügen
//
// ViewController.swift
// Persistence
//
// Created by Skyleguy on 10/31/16.
// Copyright © 2016 Skyleguy. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
@IBOutlet var lineFields: [UITextField]!
override func viewDidLoad() {
super.viewDidLoad()
let filePath = self.dataFilePath()
if (FileManager.default.fileExists(atPath: filePath))
{
let array = NSArray(contentsOfFile: filePath) as! [String]
for i in 0 ..< array.count
{
lineFields[i].text = array[i]
}
}
let notificationName = Notification.Name("applicationWillResignActive")
NotificationCenter.default.addObserver(self, selector: #selector(Persistence.applicationWillResignActive(notification: NSNotification)), name: notificationName, object: nil)
// Do any additional setup after loading the view, typically from a nib.
}
func applicationWillResignActive(notification: NSNotification)
{
let filePath = self.dataFilePath()
let array = (self.lineFields as NSArray).value(forKey: "text") as! NSArray
array.write(toFile: filePath, atomically: true)
}
}
nach all dies habe ich noch eine Störung erhalte:
„Modul‚Persistence‘hat keine Mitglied namens 'applicationWillResignAktiv' "
bitte helfen!
"Ich verstehe, dass die NotificationCenter geändert hat" Dann sind Sie falsch verstehen. Es hat sich überhaupt nicht verändert. – matt