I’m redoing the Checklist app and trying to better understand how to work with persistent memory and initialization. One thing that I’m having trouble understanding is when you need a default init() to go along with a custom init with multiple parameters. In the ChecklistItem, we created an initializer of: required init?(coder aDecoder: NSCoder) and once that code was added, another init of override init( ) was necessary to keep the compiler happy.
(1) Is this because we are telling the compiler, this is how you initialize a Checklist object that comes from NSCoder, but I need to also tell you how to initialize a Checklist object when it’s created by itself? And the default init ( ) simply runs the initializer from its superclass (NSObject)?
(2) Why does the ChecklistViewController NOT require that default init ( ) function? We also have a custom initializer for working with NSCoder in that file, but no other.
(3) In the ChecklistViewController, we have the variable, var items: [ChecklistItem], I can see how this would be initialized in that NSCoder initializer method. But when there isn’t an items object (i.e. there’s no Checklist.plist created yet), where does the initialization take place?
Thanks for your help!