Error on Dead Outlets / Actions in Interface Builder

微笑、不失礼 提交于 2019-12-14 04:21:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!