У меня есть "статический" класс, который я хочу иметь возможность реагировать на предупреждения о нехватке памяти. Однако, когда я запускаю предупреждение о нехватке памяти вручную из симулятора, я получаю сообщение об ошибке «неопознанный селектор».
Соответствующий код:
@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