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 985013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:06:11+00:00 2026-05-16T05:06:11+00:00

I am working on a project where I have a class which has UIView

  • 0

I am working on a project where I have a class which has UIView property. I also define a class which is a subclass of UIView which defines a certain method. If I have the following code, I get a warning when I build:

// In this example, myView is UIView property which *may* contain a UIView or 
// my subclassed-UIView which has the myMethod method
if([myView respondsToSelector:@selector(myMethod)]){
   [myView myMethod]
}

The warning is “UIView may not respond to ‘-myMethod'”. The warning obviously doesn’t stop the app from being built, but I am just trying to figure out how to deal with it. Is this the correct way to do this? Is there a way to stop this warning?

  • 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-16T05:06:12+00:00Added an answer on May 16, 2026 at 5:06 am

    The warning is only because the compiler doesn’t know if that view is your custom subclass. Of course, at runtime it will work fine, since it will be a subclass. You have two options to fix it:

    [myView performSelector:@selector(myMethod)];
    

    (So the compiler doesn’t check the method call at all)

    Or, better:

    [(MyViewClass *)myView  myMethod];
    

    That way the compiler acts as if the object really is your view subclass (after you performing the check of course).

    For that matter, it might make sense to check for your class rather than the method:

    if ([myView isKindOfClass:[MyViewClass class]]) { ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on a Java project for a class for a while
I have project that I'm working on that is going to require a webserver.
I'm working on a project where I have 2 web services that need the
On a recent project I have been working on in C#/ASP.NET I have some
I'm working on a project were we have number (5 at the moment) of
I am working a project that does not have a trunk / branches /
One long term project I have is working through all the exercises of SICP.
I'm currently working on project with Haskell, and have found myself some trouble. I'm
I am about to start a web project and have been working almost exclusively
Working on a project at the moment and we have to implement soft deletion

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.