Question

OK, I got it to codesign (turns out you don't need to see the code sign and embedded.mobileprovision in the build log anymore!) but I want to get rid of my "may not respond to" warnings. I cannot find the problem after looking at all the other posts about these warnings...

In the Welcome_backView.h:

 @interface Welcome_backView : UIView {
Welcome_backViewController *refParentViewController;

}


- (id)initWithParentViewController:(Welcome_backViewController *)parent;
- (void)setSubviewsToLandscape;
- (void)setSubviewsToPortrait;

In the Welcome_back.m,

  #import "Welcome_backView.h"
  #import "Welcome_backViewController.h"
  @interface Welcome_backView()
//

@end

@implementation Welcome_backView



 - (void)setSubviewsToPortrait{
//do great things
 }

 - (void)setSubviewsToLandscape{
    //do more great things
 }

Then this is from Welcome_backViewController.m:

#import "Welcome_backViewController.h"
#import "Welcome_backView.h"

@interface Welcome_backViewController()
-(void) arrangeViews;
@end

@implementation Welcome_backViewController

UIView *welcome_backView;

 - (id)init {

welcome_backView = [[Welcome_backView alloc] initWithParentViewController:self];
    self.view = welcome_backView;
}

-(void) arrangeViews {
//if one thing
    [welcome_backView setSubviewsToPortrait];
//if another thing
    [welcome_backView setSubviewsToLandscape];
}

And, like so many posters, I get the warnings "UIView" may not respond to "-setSubviewsToLandscape" (and to portrait...same warning). I have tried all the usual suspects -- misspellings of the method, using the class instead of the instance, not importing the header or having forgotten to put the method declarations in the header.

Truth is, the code seems to work fine...

Can anyone see what I've done wrong (can I get rid of the warnings)?

Was it helpful?

Solution

The warning is saying "UIView may not respond..." because you've declared the welcome_backView ivar as a UIVIew instead of your subclass of it.

UIView doesn't have the methods setSubviewsToXXX--your subclass of it does.

Change this:

UIView *welcome_backView;

to this:

Welcome_backView *welcome_backView;

It works even when declared as UIView because at run-time, the ivar does point to an instance of Welcome_backView which responds to the setSubviewsToXXX methods.

Another thing that isn't causing problems (yet) is the names of the methods. Method names starting with "set" are generally used for property setter methods and could later cause confusion.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top