0
下面的代碼在每次保存任務時都會導致崩潰。新數據需要輸入到Detail View控制器並保存。這可以工作,但應用程序每次都會終止。請告訴我這是爲什麼不工作:發送到實例Swift 2.1的無法識別的選擇器
代碼:
var detailViewController: DetailViewController? = nil
var managedObjectContext: NSManagedObjectContext? = nil
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.navigationItem.leftBarButtonItem = self.editButtonItem()
let addButton = UIBarButtonItem(barButtonSystemItem: .Add, target: self, action: "addNewCourseWork")
self.navigationItem.rightBarButtonItem = addButton
if let split = self.splitViewController {
let controllers = split.viewControllers
self.detailViewController = (controllers[controllers.count-1] as! UINavigationController).topViewController as? DetailViewController
}
//hide blank cells
let backgroundView = UIView(frame: CGRectZero)
tableView.tableFooterView = backgroundView
// register for receiving notification, I need to update detail view from this exact same class, not just any MasterView class instance...
NSNotificationCenter.defaultCenter().addObserver(self, selector:"MasterViewController.pushNewValuesToDetail", name: "updateDetailTableValues", object: nil)
}
func pushNewValuesToDetail() {
self.performSegueWithIdentifier("showDetail", sender: nil)
}
錯誤:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- MasterViewController.pushNewValuesToDetail]: unrecognized selector sent to instance 0x7fc622d1b820
[無法識別的選擇器發送到實例]的可能重複(http://stackoverflow.com/questions/2455161/unrecognized-selector-sent-to-instance) – Michael
隨意標記您的問題解決,如果它已解決。 – Putz1103