Try this with a plain new Single View application template, so in the storyboard there is only 1 view controller
In the ViewController
class ViewController: UIViewController {
override func awakeAfterUsingCoder(aDecoder: NSCoder) -> AnyObject? {
print(self)
return self
}
}
We can see that it is printed 3 times, why is that?
In the spec
Overridden by subclasses to substitute another object in place of the object that was decoded and subsequently received this message.
You can use this method to eliminate redundant objects created by the coder. For example, if after decoding an object you discover that an equivalent object already exists, you can return the existing object. If a replacement is returned, your overriding method is responsible for releasing the receiver.
This method is invoked by NSCoder. NSObject’s implementation simply returns self.
Why is it called many times?