问题
Is there a way to have Xcode refuse to build an app due to there being a dead outlet or action in my Xib, Nib or Storyboards ? I quite often build an app only to find it crashes due to a interface builder file is pointing to a key on my class which no longer exists.
I am slowly coming to the conclusion it is better to construct these pieces of UI programatically but I was wondering if there is a way at least for my older projects of Xcode warning me against these things ?
回答1:
Well, it can't. The nature of Objective-C is dynamic so the connection between xib and code can not be sure in the compile/link stage.
You may implement
-(void)setValue:(id)value forUndefinedKey:(NSString *)key{ NSLog(@"Key:%@", key);}
To find out what is missing. (Missing outlets will finally reach here.)
来源:https://stackoverflow.com/questions/20655005/error-on-dead-outlets-actions-in-interface-builder