A.swift
class A: UIView {
override init() {
super.init()
println("init A")
}
override init(frame: CGRect) {
super.init(frame: frame)
println("initFrame A")
}
}
B.swift
class B: A {
override init() {
super.init()
//P1
println("init B")
}
override init(frame: CGRect) {
super.init(frame: frame)
println("initFrame B")
}
}
Then I call it B()
:
I have an output:
initFrame A
initFrame B
init A
init B
I try to determine what? is called and when?... after B()
. I wish to understand it completely.
init()
inA
super.init()
ininit()
inA
init()
inB
super.init()
ininit()
inB
init()
inUIView
super.init()
ininit()
inUIView
now we are in P1
point, right?
init()
callsinit(frame:)
inB
withCGRectZero
super.init(frame:)
ininit(frame:)
inB
init(frame:)
inA
super.init(frame:)
ininit(frame:)
inA
init(frame:)
inUIView
super.init(frame:)
ininit(frame:)
inUIView
now we are getting back
- called the rest of
init(frame:)
inUIView
- called the rest of
init(frame:)
inA
--> initFrame A - called the rest of
init(frame:)
inB
--> initFrame B
The question is what is happening now? Where we are now? (inside init()
in UIView
?) Where are printed the lines with init A
and init B
?
Thanks for help.