Custom NSUserNotifictation object

116 Views Asked by At

I am trying to modify the NSUserNotifictation to pass custom variables:

@interface MyUserNotification: NSUserNotification
@property (nonatomic) int theid;
@property (nonatomic) NSString* url;
@end

@implementation MyUserNotification
@end

Then when initiating in my AppDelegate object:

MyUserNotification *notification = [[MyUserNotification alloc] init];
notification.theid = theid;

setting theid throws the error:

-[_NSConcreteUserNotification setTheid:]: unrecognized selector sent to instance 0x100204840

Why is NSConcreteUserNotification object getting involved?

1

There are 1 best solutions below

2
On BEST ANSWER

so this class isn't meant to be overridden it seems, but good news: there a userInfo dict?

So you can store whatever objects as KV pairs in a userInfo dict...

int theid;
NSUserNotification *notification = [[NSUserNotification alloc] init];
NSDictionary * userInfo = [NSMutableDictionary dictionary];
[userInfo setValue:@(theid) forKey:@"theid"];
notification.userInfo = userInfo;