开发者

is IBAction mandatory to reflect a method on Interface Builder?

What is the difference between below two methods, both are meant for mapping through Interface builder

- (void) showNYTimes:(id)sender
          a开发者_如何学Cnd 
- (IBAction) showNYTimes:(id)sender

Both are working perfectly for my requirement, I am able to map both ways on IB. But which one to opt, is IBAction meant for only readability of code?

Thanks.


IBAction is #defined as void, so as far as Objective C is concerned they're the same; it's meant to be a signal to Interface Builder that this particular method is available to be hooked up to a view. "IBAction - Type qualifier used by Interface Builder to synchronize actions added programmatically with its internal list of action methods defined for a project."

So it's more than just readability; it's a declaration that's meaningful to IB. I'm not sure how you were able to map your (void) method in Interface Builder, though. Only (IBAction) methods have the little circle in the gutter for me.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜