Reputation: 347
I am setting the dictionary with NSNmuber- number
(for alarm) with :
#define kTimerNameKey @"kTimerNameKey"
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:number forKey:kTimerNameKey];
When i get on the delegate a notification i have this :
NSDictionary *userInfo = notification.userInfo;
i can log it and see that its ok.
My problem is , how can i extract from userInfo
, the number for the key ?
if i use objectForKey:kTimerNameKey
, he doesnt know this key(its in another class)
So, extracting on the delegate the number from the userInfo is my problem. Thanks.
Upvotes: 0
Views: 270
Reputation: 22930
for (NSString* key in userInfo)
{
int value = [[userInfo objectForKey:key] intValue];
}
or pass key to another class.
Upvotes: 1
Reputation: 11607
Can't you just #import "YourOtherClass.h" that contains the definition for the kTimerNameKey ?
Otherwise, if you're using NSNotification to post notification, you can pass along the value of the number:
[[NSNotificationCenter defaultCenter] postNotificationName:@"notif_sendNumber" Object:myNumber];
then in your receiving class, you can go:
-(void)myReceivingMethod:(NSNotification *)notification
{
NSNumber *receivedNumber = (NSNumber *)[notification object];
}
Upvotes: 0
Reputation: 7072
Try to convert this class to int, like [[userinfo objectForKey:kTimerNameKey] intValue];
Hope it works...
Upvotes: 1