---
title: "Uses of UIResponder in Objective-C"  
description: "The UIResponder class defines an interface for objects that respond to and handle events."  
author: "Tarun Kumar"  
published: 2015-11-04  
updated: 2019-10-11  
canonical: https://www.mindstick.com/articles/11900/uses-of-uiresponder-in-objective-c  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 2 minutes  

---

# Uses of UIResponder in Objective-C

UIResponder is a sub-class of NSObject class and it has many sub-classes, some of them are UIApplication, UIView, UIWindow, UIViewController. UIResponder class was came with iOS 2.0. It has very important role in iPhone, iPad [app development](https://www.mindstick.com/services/mobile-app-development). iOS apps recognize combinations of touches and responds to them, such as zooming in/out on contents, pinching gesture and scrolling through content in [response](https://yourviews.mindstick.com/view/86896/biden-s-assertive-response-to-special-counsel-critique-on-memory-strength) to a flicking gesture. Some gestures are so common that they are built in to UIKit, like: UIControl subclasses such as UIButton and UISlider. [Instances](https://answers.mindstick.com/qa/92508/how-can-you-hide-the-sql-server-instances) of these classes are sometime [referred to as](https://answers.mindstick.com/qa/97098/which-layers-are-referred-to-as-network-support-layers) [responder](https://www.mindstick.com/interview/23134/what-is-the-first-responder-and-responder-chain-in-ios) objects.

##### There are two general kinds of events:

* Touch Events\
* Motion Events

**Touch Events:** this type of events occurs whenever any type of touch on device screen happens. like UIButton and UISlider classes [having specific](https://www.mindstick.com/forum/159130/how-to-list-all-tables-in-a-schema-having-specific-column-in-oracle-sql) gestures like: tap for a button and drag for a slider. They send an action message to a target object whenever touch occurs. It works when we attach a gesture recognizer to a view, entire view acts like a control, they respond whenever we specify gesture on device view.\

##### Important Touch Event methods:

touchesBegan:(NSSet *)setName withEvent:(UIEvent *)eventName;\
- it tells the receiver when one or more fingers touch down in a view or window.

touchesMoved:(NSSet *)setName withEvent:(UIEvent *)eventName;\
- it sent to the receiver when a system event(such as a log-memory warning) cancels a touch event.

touchesEnded:(NSSet *)setName withEvent:(UIEvent *)eventName;\
- it tells the receiver when one or more fingers are raised from a view or window.

touchesCancelled:(NSSet *)setName withEvent:(UIEvent *)eventName;\
- it tells the receiver when one or more fingers associated with an event move within a view or window.

All of these methods [parameters](https://www.mindstick.com/articles/87/passing-parameters-in-c-sharp) are associate with their events, they also handles multi-[touch gestures](https://answers.mindstick.com/qa/109447/why-won-t-my-phone-s-screen-respond-to-the-touch-gestures-after-a-recent-replace) events.

**Motion Events:** this type of events occurs whenever we shake [iPhone or iPad](https://answers.mindstick.com/qa/50335/how-to-restore-your-iphone-or-ipad-from-a-backup) devices. motion events introduces in iOS 3.0, specifically the motion of shaking the device.\

##### Its important Motion Event methods:

*motionBegan:(UIEventSubtype*)subType withEvent:(UIEvent*)eventName;*\
- it tells the receiver that motion event has begun.

*motionEnded:(UIEventSubtype*)subType withEvent:(UIEvent*)eventName;*\
- it tells the receiver that motion event has been cancelled.

*motionCancelled:(UIEventSubtype*)subType withEvent:(UIEvent*)eventName;*\
- it tells the receiver that motion event has ended

In iOS 3.0 adds an additional method- canPerformAction:withSender: method, it allows responders to validate commands in the [user interface](https://www.mindstick.com/blog/302016/what-is-user-interface-and-what-are-its-benefits).\
In iOS 4.0, UIResponder adds an other method for Remote Events- remoteControlReceivedWithEvent: method, it handles remoteControl related events.

---

Original Source: https://www.mindstick.com/articles/11900/uses-of-uiresponder-in-objective-c

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
