Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 660955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:12:52+00:00 2026-05-13T23:12:52+00:00

I have some functionality that I need in all my classes which derive from

  • 0

I have some functionality that I need in all my classes which derive from either UIView or UIImageView.

More specifically, I have gesture related code that both these classes need.
Currently my implementation is:

UIGestureView : UIView
UIGestureImageView : UIImageView

and make all classes derive from these.
These classes will again contain methods that the derived class will implement.

My problem is that the gesture handling code is duplicated in UIGestureView and in UIGestureImageView.

The natural thing here (as a c++ programmer) would be to use multiple inheritance

UIGestureView : UIView, GestureHandler
UIGestureImageView : UIImageView, GestureHandler

and let GestureHandler perform all the generic work but as far as I have understood this is not possible.

What is the objective-c way of doing this (without too many levels of child calling parent etc.)?

Just to stress, the problem is how to avoid implementing the same code twice, once in UIView (or its derived class) and again for UIImageView (or its derived class).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T23:12:52+00:00Added an answer on May 13, 2026 at 11:12 pm

    You could extend UIView with your gesture handling, and then every objects that inherits from UIView will have the methods you want. Not quite as awesome and subclassing, but would work on the global scope.

    @interface UIView (GestureHandling)
    
    - (void)didMoveAFinger:(UITouch*)touchOrWhatever;
    // etc., etc.
    
    @end
    

    I have had similar issues with UIViewController and UITableViewController. I have a subclass of one that I want to share code with the subclass of the other. Yet there is no common place to inject that code if you want a subclass. The alternative is categories on the common superclass.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a set of classes, each of which need to decide at some
I have some functionality that needs to be async in my C# app. It's
I have a C# class that has some functionality that I'd like to allow
Let's say that I have class , that uses some functionality of dict .
Suppose I have a Generic abstract class that provides some default constructor functionality so
I would like to have some functionality by which if I write <textarea maxlength=50></textarea>
Suppose we have an abstract class Element from which classes Triangle and Quadrilateral are
Suppose we have 2 classes, Child, and the class from which it inherits, Parent.
In C++, I have an Object class, from which a number of other classes
I need to write some JavaScript functionality that analyses an address block and displays

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.