I am trying to pass a variable to another view via code. When a user clicks on a table view data my app passes the table data to the next view. But I am getting a "class has no initialisers" on my second screen:
Table view calling 2nd screen on click:
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
{
let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let nextViewController = storyBoard.instantiateViewControllerWithIdentifier("editFriend") as! EditFriendViewController
self.presentViewController(nextViewController, animated: true, completion: nil)
nextViewController.friend = friendArray[indexPath.row];
}
2nd screen code:
import UIKit
import CoreData
class EditFriendViewController: UIViewController {
var friend: Friends
@IBOutlet weak var fName: UITextField!
@IBOutlet weak var lName: UITextField!
@IBOutlet weak var mobile: UITextField!
@IBOutlet weak var gender: UIPickerView!
@IBOutlet weak var address: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
fName.text = friend.firstName!;
lName.text = friend.lastName!;
mobile.text = friend.mobile!;
address.text = friend.address!;
}
}