Nilesh Agrawal Nilesh Agrawal - 22 days ago 5
iOS Question

Difference between sendEvent and Send Action in ios

I am trying to intercept the iOS UI events, I found that

sendEvent
can be used to do it.
I also tried to intercept UI events using
sendAction:to:from:forEvent
.

I wanted to know what the difference is between these two methods. Is the
sendAction:to:from:forEvent
more efficient?

Answer

may be this will help you

sendAction:to:from:forEvent:

Sends an action message identified by selector to a specified target

- (BOOL)sendAction:(SEL)action
                to:(id)target
              from:(id)sender
          forEvent:(UIEvent *)event

**action:**A selector identifying an action method. See the discussion for information on the permitted selector forms.

**target:**The object to receive the action message. If target is nil, the app sends the message to the first responder, from whence it progresses up the responder chain until it is handled.

**sender:**The object that is sending the action message. The default sender is the UIControl object that invokes this method.

**event:**A UIEvent object that encapsulates information about the event originating the action message.

- (void)sendEvent:(UIEvent *)event

Dispatches an event to the appropriate responder objects in the app.

**event:**A UIEvent object encapsulating the information about an event, including the touches involved.

look at this https://developer.apple.com/library/ios/DOCUMENTATION/UIKit/Reference/UIApplication_Class/index.html#//apple_ref/occ/instm/UIApplication/sendEvent: