I have 2 view controllers, VC1 displays all the users on my apps basic info, when you press a more info button in a certain cell it segues to a new VC that displays the users full profile that was in the cell that you previously pressed.
With help I have everything working except for how to display the results on VC2. I am trying to set a property in the VC2. I also tried for
This code is returning no errors but displays nothing on the VC2.
I've tried set, get willSet, everything and can't crack it:
var userToShowDetail: PFUser? {
willSet {
self.configureView()
}
}
func configureView() {
// Update the user interface for the detail item.
if let userToShowDetail: PFUser = self.userToShowDetail {
if let label = self.userName {
userName.text = userToShowDetail["name"] as! String?
}
}
}
override func viewDidLoad() {
I tried this one but it returns nothing but an empty VC:
var userToShowDetail: PFUser?
override func viewDidLoad() {
super.viewDidLoad()
if let appUsers = userToShowDetail as PFUser? {
self.userName.text = appUsers["name"] as? String
self.userInstrument.text = appUsers["instrument"] as? String
self.userAge.text = appUsers["age"] as? String
self.userProfile.file = appUsers["image"] as? PFFile
self.userProfile.layer.cornerRadius = self.userProfile.frame.size.width/2
self.userProfile.clipsToBounds = true
self.userProfile.loadInBackground()
}
I have researched didSet and willSet but I am still at a loss. Any help would be greatly appreciated. What is the next step can someone point me to a tutorial or advise me please.
willSet and DidSet purpose Apple properties
View Controller 1 segue:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "userProfileDetailsSegue" {
//get the index path for the row that was selected
let indexPath = self.resultsPageTableView.indexPathForSelectedRow!
//get the PFUser object for that particular row
let userToShow = self.appUsers[indexPath.row]
//create your new view controller
let newVc = segue.destinationViewController as! UserProfileDetailsViewController
//assign the new vc's property to your object
newVc.userToShowDetail = userToShow
}
}