Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Enara L. Otaegi
13,107 PointsawakeFromNib and the settings bundle
So, I'm reading iOS App Programming Guide, and I have a question to anyone who can answer me this. When we use storyboard and the app launches, the archive that stores the serialized attributes from the storyboard is loaded with the initWithCoder method. (I assume we don't have to do anything here) But, then the method awakeFromNib is called to load any object that has a default configuration or to restore an object to some previous state. So my question is, in the currency app where we create a settings bundle I changed the code to this
- (void)viewDidLoad
{
[super viewDidLoad];
[self.view addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissKeyboard:)]];
}
- (void)awakeFromNib {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateSettings:) name:NSUserDefaultsDidChangeNotification object:nil];
[self setupDefaults];
}
and it works fine but is this efficient or the awakeFromNib is for loading another kind of configuration. Thank you!