I have just noticed that my ViewController does not call init (See below) when it starts up.
-(id)init {
self = [super init];
if(self) {
NSLog(@"_init: %@", [self class]);
otherStuff...
}
return self;
}
Is there a reason for this, or is it replaced by viewDidLoad
-(void)viewDidLoad {
otherStuff ..
[super viewDidLoad];
}
cheers gary
By default, SwiftUI assumes that you don't want to localize stored strings, but if you do, you can first create a localized string key from the value, and initialize the text view with that. Using a key as input triggers the init(_:tableName:bundle:comment:) method instead.
A view controller manages a single root view, which may itself contain any number of subviews. User interactions with that view hierarchy are handled by your view controller, which coordinates with other objects of your app as needed. Every app has at least one view controller whose content fills the main window.
init(coder:)Returns an object initialized from data in a given unarchiver.
Swift init() Initialization is the process of preparing an instance of a class, structure, or enumeration for use. This process involves setting an initial value for each stored property on that instance and performing any other setup or initialization that is required before the new instance is ready for use.
It's not replaced by viewDidLoad
. It's just that init's not called by initWithNibName:bundle:
.
I just write my setup code in viewDidLoad
.
If your view controller is being initialized from a storyboard, then you can use:
- (instancetype)initWithCoder:(NSCoder *)coder
{
self = [super initWithCoder:coder];
if (self) {
// do init here
}
return self;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With