开发者

How to get a compiler warning when an IBOutlet is disconnected

How can I have Xcode warn me if an IBOutlet of one of my objects is not hooked up to anything in a NIB?

I can check that outlets are connected at runtime by adding assert(ofEveryOu开发者_如何学JAVAtlet); in awakeFromNib or viewDidLoad. But it's not as useful, or reliable, as having the compiler do the checking for me.


Why not create a Unit Test target that checks your IB bindings and make your application depend on it. That way it will get checked each time you build. See http://blog.carbonfive.com/2010/03/testing/testing-view-controllers for an example of this approach


The (compiled) NIB files are loaded and connected at runtime, so I don't think there is a way for the compiler to check this. I think your best bet is the asserts you've already suggested...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜