Extend UILocalNotification

2020-04-09 13:41发布

问题:

I beginner in iOS. I try extend UILocalNotification. My class below.

@interface FSCustomNatification : UILocalNotification

typedef enum {
    FSCustomNatificationPay,
    FSCustomNatificationWrite,
    FSCustomNatificationSend
} NotificationTypeT;

@property (nonatomic, assign) NotificationTypeT typeNotificationT;


@end



#import "FSCustomNatification.h"

@implementation FSCustomNatification



@end

When I set typeNotificationT property I get -[UIConcreteLocalNotification setTypeNotificationT:]: unrecognized selector sent to instance 0x8144780. Why?

FSCustomNatification* localNotification = [[FSCustomNatification alloc] init];
localNotification.typeNotificationT = FSCustomNatificationWrite;

回答1:

By the looks of your error message UILocalNotification is part of a class cluster. The docs don't say (that I can see quickly) but it seems unlikely that you should subclass UILocalNotification.

Instead, you should make use of the userInfo provided by UILocalNotification to add any extra information you want to be available when the notification fires.