琐碎的“ + [NSTimerchededTimerWithTimeInterval:repeats:block:]:无法识别的选择器”;错误 [英] Trivial "+[NSTimer scheduledTimerWithTimeInterval:repeats:block:]: unrecognized selector" error
问题描述
在移至10.12 / Sierra和Xcode 8.1之后,我正在努力应对奇怪的错误:
I am banging my head against an odd error after a move to 10.12/Sierra and Xcode 8.1:
+[NSTimer scheduledTimerWithTimeInterval:repeats:block:]:
unrecognized selector sent to class 0x7fff78f1fa88
最小复制此代码的代码(创建新项目的默认设置)是:
The most minimal code (default settings of create a new project) to reproduce this is:
// AppDelegate.m
//
#import "AppDelegate.h"
@interface AppDelegate ()
@property (weak) IBOutlet NSWindow *window;
@property (strong, nonatomic) NSTimer * timer;
@end
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
self.timer = [NSTimer scheduledTimerWithTimeInterval:10
repeats:YES
block:^(NSTimer * _Nonnull timer)
{
NSLog(@"Ping from %@", timer);
}];
}
链接包括(Core)Foundation类和 all_load。必须完全是微不足道的-但不能做到这一点。
The linking includes the (Core)Foundation classes and 'all_load'. Must be something totally trivial - but fail to what it is.
任何人都应感谢所有帮助。
Any and all help appreciated.
谢谢,
Dw。
推荐答案
+ [NSTimercheduledTimerWithTimeInterval:repeats: block:]是一种iOS 10.0+方法。您是不是想在iOS 9.x上运行它?
+[NSTimer scheduledTimerWithTimeInterval:repeats:block:] is an iOS 10.0+ method. Are you maybe trying to run it on iOS 9.x?
这篇关于琐碎的“ + [NSTimerchededTimerWithTimeInterval:repeats:block:]:无法识别的选择器”;错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!