Имам клас, подобен на "статичен", който искам да мога да реагирам на предупреждения за недостиг на памет. Въпреки това, когато задействам предупреждението за ниска памет ръчно от симулатора, получавам грешка „неразпознат селектор“.
Подходящ код:
@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