I have two ViewControllers, FirstViewController
and SecondViewController
. Both have an own Swift file, FirstViewController.swift
and
If you want to show alert view to second viewcontroller
from firstview controller
when go to it you can do something like,
self.performSegueWithIdentifier("your segue identifier", sender: self) // or whatever way if you are not using storyboard or segue
let alert = UIAlertView(title: "Working!", message: "This function was called from FirstViewController!", delegate: nil, cancelButtonTitle: "Okay")
alert.show()
If you want to set any variables
of secondviewcontroller
then you need to implement prepareForSegue
method. (if you are using segue).
Second thing you can show alertview in viewDidload
of secondViewController
also.