On Jan 12, 2010, at 11:51 AM, Rainer Standke wrote:
> NSArray *theContextInfo = [[NSArray alloc] init];
> theContextInfo = [NSArray arrayWithObject:objTBD];
Well that's a leak already... The alloc/init is a waste.
> [NSApp beginSheet: alertWindow
> modalForWindow: [self windowForSheet]
> modalDelegate: self
> didEndSelector: @selector(didEndSheet:returnCode:contextInfo:)
> contextInfo: theContextInfo];
And here you passed an autoreleased object as the context info which means it's
going to be deallocated at the end of the run loop. You should be passing a
retained object to context info...
> - (void)didEndSheet:(NSWindow *)sheet returnCode:(int)returnCode
> contextInfo:(void *)contextInfo
> {
And grabbing it here, and releasing it somehow to balance the retain.
NSArray * array = [(NSArray *)contextInfo autorelease];
> The contextinfo's class is logged as NSConcreteMutableData.
Because that pointer is now pointing at entirely different object. Your array
has already been deallocated and an NSMutableData instance took its place.
> Why is contextinfo considered to be of class void in the signature?
Because void * can be a pointer to *anything*. contextInfo is not just limited
to Obj-C objects. You could pass a pointer to an integer if you wanted. (It's
even not out of the question to pass an integer value directly to contextInfo
instead of using a pointer to one.)
--
Seth Willits
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]