警告:-method:在协议中找不到

时间:2011-09-05 12:28:48

标签: ios

每次编译时都会收到此警告。

警告:在协议中找不到方法。

这是我在TableViewController.m文件中的代码。

@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;

我是否收到此警告,因为它是+ classMethod:?我怎么能绕过这个?

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

阅读this stackOverflow thread ..你的方法'classMethod'是一个类方法(多么讽刺),你不能使用该类的对象来调用它。

使用

[SubClass classMethod];

调用该函数..

相关问题