I have the following situation:
I have created a rightBarButtonItem in my viewDidLoad:
self.navigationItem.rightBarButtonItem = UIBarButtonItem.init(title: "New", style: .Plain, target: self, action: "newProject")
My question is, how can I move through tapping this button programmatically to another Viewcontroller, using the segue "show (e.g push)".
I have the beginning like this:
func newProject() {
}
But I don't know further, because I'm a beginner in Swift.
Any help would be really appreciated!
Update:
So, this is the whole area, where the error appears:
class NewProject: UIViewController, UITextFieldDelegate, UITextViewDelegate, CustomPickerDelegate {
@IBOutlet weak var txtProjectName: UITextField!
@IBOutlet weak var tvDescription: UITextView!
@IBOutlet weak var txtStartDate: UITextField!
@IBOutlet weak var txtEndDate: UITextField!
var hud: MBProgressHUD?
var customPicker: CustomPickerView?
var dictProject: NSDictionary!
var projectID: String!
override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.title = "Create new Project"
self.hud = MBProgressHUD(view: self.view)
self.view.addSubview(self.hud!)
self.projectID = ("\(self.dictProject!["id"]!)")
self.populateFields()
}
func populateFields() {
if nil != self.dictProject!["name"] {
self.txtProjectName.text = self.dictProject!["name"] as? String
}
}
And the error appears on this line here:
self.projectID = ("\(self.dictProject!["id"]!)")
And this line here:
if nil != self.dictProject!["name"] {
Give your segue an identifier in the storyboard (i.e. "NewProject"
) and then perform it like this:
func newProject() {
performSegueWithIdentifier("NewProject", sender: self)
}