.h
#import <Foundation/Foundation.h>
#import "Person.h"
extern NSString *const kRemindersWeekly;
extern NSString *const kRemindersDaily;
@interface Reminders : NSObject
+(void)setRemindersForPerson: (Person*) person;
+(void)setEightDayReminder;
@end
.m
#import "Reminders.h"
@implementation Reminders
NSString *const kRemindersWeekly = @"WEEKLY";
NSString *const kRemindersDaily = @"DAILY";
+ (void) setRemindersForPerson: (Person*) person
{
// some code
}
+(void)setEightDayReminder
{
// some more code
}
@end
当我打电话时:
[Reminders setRemindersForPerson: p];
这总是很好用。当我打电话时:
[Reminders setEightDayReminder];
我得到:
+[Reminders setEightDayReminder]: unrecognized selector sent to class 0xe1b58
此外,[Reminders setRemindersForPerson:];
调用 [Person setEightDayReminder]
没有任何问题。构建良好,命令单击 XCode 中的函数显示它。我认为一切都井井有条,因为它将我带到适当的地方。
一定是遗漏了一些明显的东西?!拔我的头发。
最佳答案
我有一个非常相似的问题,原因是我有一个类别,我忘记在 @implementation block 中指定类别,有效地用"new"实现覆盖了原始实现。
因此,如果您在类 SomeClass 上有一个类别 MyCategory,请确保其实现如下所示:
@interface SomeClass (MyCategory) ...
并且不喜欢:
@interface SomeClass ...
关于objective-c - 发送到类的无法识别的选择器 - 对于没有参数的静态方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13602982/