tags:

views:

682

answers:

3

i'm getting this two messages:

warning: 'MainView' may not respond to '-switchToNoGridView' Messages without a matching method signature will be assumed to return 'id' and accept '...' as arguments

1st here:

//GridView.m
#import "GridView.h"
#import "MainView.h"

@implementation GridView

-(IBAction)switchToNoGridView {
    [mainView switchToNoGridView];
}

@end

2nd here:

warning: 'MainView' may not respond to '-goBack' Messages without a matching method signature will be assumed to return 'id' and accept '...' as arguments

in this:

//NoGridView.m
#import "NoGridView.h"
#import "MainView.h"

@implementation NoGridView

-(IBAction)goBack {
    [mainView goBack];
}

@end

how to avoid these warnings?

+1  A: 

Have you declared switchToNoGridView and goBack in the class interface for MainView?

This warning means that the method signatures could not be found in the class of the instance that you are calling the method on; since message dispatch in Objective-C is done at runtime this is allowed, however a warning is shown.

Perspx
A: 

I'm not quite sure from your code, but I think you're encountering one of two errors. Either:

You haven't declared the methods switchToNoGridView or goBack in the MainView class declaration. For Xcode to know that an object responds to a method, you have to include its definition in the class header file, like this:

@interface MainView : ParentObject {
    // instance variables
}
// properties
 - (void)switchToNoGridView;
 - (void)goBack;
@end

This assumes you actually want to declare them as (void), of course - they can have return values, but since you don't do anything with the result of the call in your code, I'm assuming they're void. Or:

You meant to call MainView the class, not mainView the object. Since we can't see your property or instance variable definitions for GridView.h, nor can we see the current method declarations in MainView.h, it's possible that you have a static method +(void)switchToNoGridView and +(void)goBack declared on MainView, but you're calling it on an instance mainView of MainView. For example:

@interface AClass : NSObject { }
+ (void)doSomething;
@end

@implementation AClass
+ (void)doSomething {
    NSLog(@"Doing something");
}
@end
#import "AClass.h"
@interface AnotherClass : NSObject {
    AClass *aClass;
}
@property(nonatomic,retain) AClass *aClass;
 - (void)doSomethingElse;
@end

@implementation AnotherClass
- (void)doSomethingElse {
    [aClass doSomething]; // This will break at runtime
    [AClass doSomething]; // but this won't
}
@end

Basically, it's possible you've confused class methods with object methods. Either way, you should check your MainView header file for the appropriate method definitions.

Tim
this is my MainView://MainView#import "MainView.h"#import "GridView.h"#import "NoGridView.h"@implementation MainView-(void)awakeFromNib { [self addSubview:gridView]; [self addSubview:infoView];}-(void)switchToNoGridView { [gridView removeFromSuperview]; [self addSubview:nogridView];}-(void)goBack { [nogridView removeFromSuperview]; [self addSubview:gridView];}@end
A: 

thanx tim, warnings don't show up anymore. although i still wonder that the app was working even with that warnings...

blacksheep
It was probably working because the method took no arguments and returned no values. If you had tried the same with a method that took an object as an argument or returned a non-void value, it would probably have broken.
Tim