NSNotification arrived with broken object
i'm posting notification in this manner:
...
IVSession *newSession = [[[IVSession alloc] initWithDictionary:propertyDict] autorelease];
NSDictionary *notifParams = [NSDictionary dictionaryWithObject:newSession forKey:@"session"];
NSNotification *newSessionNotif = [NSNotification notificationWithName:IVNewSessionNotificaiton object:se开发者_StackOverflow中文版lf userInfo:notifParams];
...
IVSession interface:
@interface IVSession : IVMappableObject {
NSString *_ssid;
NSNumber *_uid;
}
@property (nonatomic,retain) NSString *sessionID;
@property (nonatomic,retain) NSNumber *userID;
and init method:
- (id)initWithDictionary:(NSDictionary*)dict
{
if ((self = [super init]))
{
NSDictionary *mapping = [self elementToPropertyMappings];
for (NSString *key in mapping)
[self setValue:[dict objectForKey:key] forKey:[mapping objectForKey:key]];
}
return self;
}
but at the method, called for this notification, i'm receiving broken newSession
object - its properties ssid
and uid
are invalid summaries:
-(void)didOpenSession:(NSNotification *)newSession
{
if (receivedSession)
[receivedSession release];
receivedSession = [[newSession userInfo] objectForKey:@"session"];
}
where is my fault?
code looks ok to me... have you verified that the IVSession object contains what you expect it to, after assembling things, but prior to posting the notification?
精彩评论