0

I get this warning every time I compile.

WARNING: -method not found in protocol.

Here is my code in TableViewController.m file.

@implementation TableViewController

@synthesize delegate;

- (NSArray *) placeId
{
NSArray *places = [self.delegate classMethod: placeId];
    // WARNING SHOWS UP HERE.
}

//Here is my code in TableViewController.h file.

@class TableViewController;

@protocol TableViewControllerDelegate
+ (NSArray *) classMethod: (NSString *) placeId;
@end

@interface TableViewController : UITableViewController
{
id <TableViewControllerDelegate> delegate;
}   

@property (assign) id <TableViewControllerDelegate> delegate;
@end

//My code in SubClass.h

#import "TableViewController.h"

@interface SubClass: NSObject <TableViewControllerDelegate>

+ (NSArray *) classMethod: (NSString *) placeId;

Do I get this warning because it is a + classMethod:? How can I get around this?

Any help would be greatly appreciated.

mark
  • 1
  • Are you sure that you need method `classMethod` to be static? `+ (NSArray *) classMethod: (NSString *) placeId;` =?>`- (NSArray *) classMethod: (NSString *) placeId;` – Nekto Sep 05 '11 at 12:32

1 Answers1

0

Read this stackOverflow thread..your method 'classMethod' is a Class Method (how ironic) and you cannot call it using an object of that class..

Use

[SubClass classMethod];

to call that function..

Community
  • 1
  • 1
Krishnabhadra
  • 34,169
  • 30
  • 118
  • 167
  • `[[[self delegate] class] classMethod]`. The delegate doesn't have to be necessarily a `SubClass` instance. – albertamg Sep 05 '11 at 13:03
  • ...both calls would work regardless. The delegate doesn't have to be a `SubClass` instance, but it will almost certainly be importing `SubClass.h`, so I think it's a moot point. – lxt Sep 05 '11 at 14:11
  • @lxt If the delegate is not an instance of `SubClass`, you probably don't want to call `classMethod` on `SubClass` but on the delegate's class. – albertamg Sep 05 '11 at 19:01