I have 2 VCs: CouponVC and CouponFeedbackVC.
Coupon VC receives brand: Brand! from its parentViewController. Now I want to pass the brand.name to CouponFeedbackVC.
CouponVC.swift
var brandName: String!
override func viewDidLoad() {
super.viewDidLoad
brandName = brand.name
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "couponToFeedBack" {
if let vc = segue.destination as? CouponFeedbackVC {
print(brandName)
vc.brandName = self.brandName
}
}
}
In CouponFeedbackVC.swift
var brandName: String!
override func viewDidLoad() {
super.viewDidLoad()
print("viewDidLoad")
print(brandName)
}
override func awakeFromNib() {
print(brandName)
self.view.layoutIfNeeded()
}
Console Log
nil
viewDidLoad
nil
StayUncle
awakeFromNib() -> viewDidLoad() -> prepare(for segue:)
I am not accessing any outlets from CouponFeedbackVC.
Why is prepare(for segue: ) being called after viewDidLoad() and awakeFromNib()?