iOS

Outlet and Action

Outlet

ViewController talks to View by using Outlet.

Any object(UILabel,UIButton,UIImage,UIView etc) in View can have an Outlet connection to ViewController.Outlet is used as @property in ViewController which means that:

1.The Outlet gives your class(typically a view controller) a reference to a child view in the xib. 2.The outlet gives the obj-c code access to anobject in IB. 3.Outlet is used when you want to change some property of control such as text color or text size of a label.

Action

View pass on messages about view to ViewController by using Action (Or in technical terms ViewController set itself as target for any Action in View).Action is a Method in ViewController(unlike Outlet which is @property in ViewController).Whenever something(any Event) happens to an object(like UIButton is tapped) then Action pass on message to ViewController.Action(or action method) can do something after receiving the message.

Note: Action can be set only by UIControl’s child object.Which means you can not set Action for UILabel,UIView etc.

1.The action provides a method to be called by a control(usually also a child view on the xib)when activated by the user. 2.The action gives the xib control access to the obj-c. 3.Action is used when you want to detect a trigger such as the button is pressed.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s