I can't use initWithNibName:bundle seeing as I'm now using the latest XCode (5). After some research I found an alternative: initWithCoder.
Example:
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self){
// code here
}
return self;
}
What I'm trying to understand is how this is an alternative to initWithNibName?
Currently studying with a big nerd ranch book for ios which was written for ios6 and previous versions of xode and experimenting with the coreLocation framework.
In the code below I've replaced the initWithNibName. I also done this in an earlier tutorial using that same initializer and it worked but I have trouble moving on in tutorial books if I don't fully understand a chapter. The apple docs don't always make sense instantly. Usually a combination of stackoverflow answers and re-reading helps things sink in.
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self){
//create location manager object
locationManager = [[CLLocationManager alloc] init];
//there will be a warning from this line of code
[locationManager setDelegate:self];
//and we want it to be as accurate as possible
//regardless of how much time/power it takes
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
//tell our manager to start looking for it location immediately
[locationManager startUpdatingLocation];
}
return self;
}
What is the code above doing? It looks like a designated initializer but the name and the return type of the argument baffle me. Would appreciation some help here.
Kind regards
Update:
From what I've gathered in XCode 5 the use of storyboards is encouraged and I don't see an option to not use storyboards. The tutorials I'm following from this book are using XCode 4.3 where nibs were available.