Duplicate NSLog entries
I don't know if it's possible for me to include code here that's relevant as my project is so large but are there any typical reasons why NSLog
would repeat some warnings and calls to it at occasions where only one call/error is occuring?
As an example, I have a subclass of NSBox
that inits an instance of another class on awakeFromNib
:
- (void) awakeFromNib {
burbControllerInstance = [[BurbController alloc] init];
if (burbControllerInstance) {
NSLog(@"init ok");
}
}
I get NSLog
printing "init ok" twice. I don't see why this subclass would be 'awoken' twice anywhere in my project. This is part of a larger problem where I can't get variables to return anything but nil
fro开发者_开发问答m the class I'm creating an instance of. I'm wondering if perhaps the double values are something to do with it.
This post could be helpful, i. e. one comment:
Also important: awakeFromNib can be called multiple times on the controller if you use the same controller for several nibs – say, you’re using the app delegate as the owner of both the app’s About Box and preferences dialog. So you’ll need an extra guard test if you use awakeFromNib for anything but initializing the nib objects
Update: Much more interesting could also be this, where the author mentions that awakeFromNib
gets called twice. Unfortunately there is no real answer for this particular problem but maybe some basic ideas.
Update #2: Another potential solution from stackoverflow.com: View Controller calls awakeFromNib twice.
精彩评论