I have a view, which will call Alice. In turn, Alice has a subview named Bob. Bob, in turn, has a subview named Carol. Alice and Bob are designed in Interface Builder, while Carol is an Apple-framework view.
Bob has a property to store Carol, and the storing takes place in Bob's addSubview:
However, Alice must call Bob's doSomething function, wherein Bob must then set a property on Carol. Thus, the call takes place in Alice's layoutSubviews function. Here's Bob's doSomething message:
Alice's layoutSubviews method looks something like this:
However, this solution appears to be invalid because "Carol", the property, hasn't been set yet. Further, the view hierarchy I defined in Interface Builder is exactly what I want it to be.
So my question is, where is the best place to put my call to doSomething()?
Bob has a property to store Carol, and the storing takes place in Bob's addSubview:
Code:
override func addSubview(_ view: UIView) {
super.addSubview(view)
Carol = view as? UIImageView
}
However, Alice must call Bob's doSomething function, wherein Bob must then set a property on Carol. Thus, the call takes place in Alice's layoutSubviews function. Here's Bob's doSomething message:
Code:
func doSomething(theCase: CaseType) {
self.isHidden = false
switch theCase {
...
case .case2:
Carol.isHidden = false
default: break
}
}
Alice's layoutSubviews method looks something like this:
Code:
override func layoutSubviews()
{
super.layoutSubviews()
Bob.doSomething()
}
However, this solution appears to be invalid because "Carol", the property, hasn't been set yet. Further, the view hierarchy I defined in Interface Builder is exactly what I want it to be.
So my question is, where is the best place to put my call to doSomething()?