我有一个类似“静态”的类,我希望能够响应低内存警告。但是,当我从模拟器手动触发内存不足警告时,我收到“无法识别的选择器”错误。
相关代码:
@interface MyClass : NSObject
+ (void) receiveNotification:(NSNotification*) notification;
@end
@implementation MyClass
+ (void) initialize {
[super initialize];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveNotification) name:@"UIApplicationDidReceiveMemoryWarningNotification" object:nil];
}
+ (void) receiveNotification:(NSNotification*) notification {
// Breakpoint here never hits.
// I instead receive error "+[MyClass receiveNotification]: unrecognized selector sent to class".
}
@end