2013-08-19 84 views
4

我在iOS的初學者。我嘗試擴展UILocalNotification。我的課程在下面。延伸UILocalNotification

@interface FSCustomNatification : UILocalNotification 

typedef enum { 
    FSCustomNatificationPay, 
    FSCustomNatificationWrite, 
    FSCustomNatificationSend 
} NotificationTypeT; 

@property (nonatomic, assign) NotificationTypeT typeNotificationT; 


@end 



#import "FSCustomNatification.h" 

@implementation FSCustomNatification 



@end 

當我設置typeNotificationT財產,我得到 - [UIConcreteLocalNotification setTypeNotificationT:]:無法識別的選擇發送到實例0x8144780。爲什麼?

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

你試過重寫'init'嗎?它看起來像是認爲'localNotification'是'UIConcreteLocalNotification'而不是'FSCustomNatification'。另外,你的班名中有一個a而不是o。 – thegrinner

+0

是的,我嘗試了overrite初始化。 – fisher3421

回答

6

通過您的錯誤消息的外觀UILocalNotification是類集羣的一部分。文檔沒有說(我可以很快看到),但似乎不太可能應該繼承UILocalNotification

取而代之,您應該使用UILocalNotification提供的userInfo來添加您希望在通知觸發時可用的任何額外信息。