【发布时间】:2016-02-27 16:05:18
【问题描述】:
我正在创建一个简单的“解决方案”应用程序,但在将当前视图控制器转换为 MasterViewControllet 时遇到了一个问题 - 我想这样做来设置它的一些变量。 我得到的错误是“无法将'UINavigationController'(0x10c534670)类型的值转换为'Resolution_App.MasterViewController'(0x10ac97d00)。” 这是我的主要故事板: 这是我的“添加新分辨率”视图控制器中的代码 请,关于如何正确投射它的任何建议?
class EditViewController: UIViewController {
@IBOutlet weak var resolutionTitle: UITextField!
@IBOutlet weak var achievedDate: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func saveButton(sender: AnyObject) {
var newResolution = ["name":resolutionTitle.text,"achievingDate":achievedDate.text,"startingDate":"\(NSDate())"] as Dictionary<String,String>
var destinationController = presentingViewController as! MasterViewController
destinationController.objects.insert(newResolution, atIndex: 0)
destinationController.notifyTableViewForNewInsertion()
destinationController.saveDateToFile()
self.dismissViewControllerAnimated(true, completion: {})
}
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
}
【问题讨论】:
标签: ios swift model-view-controller