Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/93.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 已将无法识别的选择器发送到类-对于没有参数的静态方法_Objective C_Ios_Xcode_Static Methods - Fatal编程技术网

Objective c 已将无法识别的选择器发送到类-对于没有参数的静态方法

Objective c 已将无法识别的选择器发送到类-对于没有参数的静态方法,objective-c,ios,xcode,static-methods,Objective C,Ios,Xcode,Static Methods,h 当我打电话时: #import "Reminders.h" @implementation Reminders NSString *const kRemindersWeekly = @"WEEKLY"; NSString *const kRemindersDaily = @"DAILY"; + (void) setRemindersForPerson: (Person*) person { // some code } +(void)setEightDayRemi

h

当我打电话时:

#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];
这总是很好用的。当我打电话时:

#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];
另外,
[提醒设置提醒ForPerson:]调用
[个人设置八天提醒]
没有任何问题。构建很好,单击XCode中的函数可以显示它。我认为一切都正常,因为它将我带到适当的位置


一定是遗漏了什么明显的东西?!把我的头发拔出来

有一种简单的调试方法——在那里放置一个断点并观察发生了什么

请参阅如何为无法识别的选择器创建断点。堆栈跟踪应该告诉您需要知道的一切


可能您也应该添加调用代码。

我遇到了一个非常类似的问题,原因是我有一个类别,我忘了在@implementation块中指定该类别,实际上用“新”实现覆盖了原始实现

因此,如果类SomeClass上有一个类别MyCategory,请确保其实现如下所示:

+[Reminders setEightDayReminder]: unrecognized selector sent to class 0xe1b58
而不是像:


当setEightDayReminder方法崩溃时,您从何处调用该方法?在调用function@Sharanya,它是一个静态方法,self指的是一个不存在的实例。我在类上调用了静态方法,提醒,而不是在实例“self”上尝试更改mathod名称MySetEightDayRequirement而不是SetEightDayRequirement。为了澄清这些不是静态方法,它们是类方法。这是有区别的,明白吗
@interface SomeClass ...