I need to send a notification using the postNotificationName:object:userInfo: , and I pass the user-defined FileItem class as userInfo to get it on the other end. Should I use autorelease , like this
FileItem *item = [[[FileItem alloc] init] autorelease]; [[NSNotificationCenter defaultCenter] postNotificationName:@"dataReceived" object:self userInfo:item]; [item release];
or can I just alloc and then release object right after passing it to the default notification center?
FileItem *item = [[FileItem alloc] init]; [[NSNotificationCenter defaultCenter] postNotificationName:@"dataReceived" object:self userInfo:item]; [item release];
I am trying to conclude an agreement here, because I assume that whenever I pass an object as a parameter in a message to another object, the receiving object will save if necessary, and that I can safely release the specified parameter
source share