开发者

Difference between IBOutlet and IBAction [duplicate]

This question already has answers here: IBOutlet and IBAction (11 answers) Closed 3 years ago.

Tell me the difference between IBOutlet and IBAction . Can we make IBOutlet as property and shall we need to re开发者_运维百科lease the IBOutlet Controller?

Thanks In Advance


An IBOutlet is for hooking up a property to a view when designing your XIB. An IBAction is for hooking a method (action) up to a view when designing your XIB.

An IBOutlet lets you reference the view from your controller code. An IBAction lets the view call a method in your controller code when the user interacts with the view.

You should release or nil IBOutlet properties in dealloc.


Number 1 google response: IBOutlet and IBAction

Yes, you can make an IBOutlet a property, and you need to release anything that you retain, so if the property is set with 'retain' attribute, then you'll need to release it.


Actions are events which the UI sends to the code when something happens. If you click on a button Cocoa will start the code that you have defined by

  1. linking the button to an action of an “interface object”
  2. calling the method of that action in the code

An Outlet is a link from code to UI. If you want to show or hide an UI element, if you want to get the text of a textfield or enable or disable an element (or a hundred other things) you have to define an outlet of that object in the sources and link that outlet through the “interface object” to the UI element. After that you can use the outlet just like any other variable in your coding.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜