On Jan 12, 2010, at 2:51 PM, Rainer Standke wrote:
> I am trying to get some contextinfo across while a sheet is displayed.
>
> Here is the code that displays the sheet:
>
> NSArray *theContextInfo = [[NSArray alloc] init];
> theContextInfo = [NSArray arrayWithObject:objTBD];
You're leaking an array here. The first [[NSArray alloc] init] is unnecessary,
since you're overwriting theContextInfo immediately afterwards. Also, if you're
just putting one object in your array, you might as well just pass that object
instead of the array in theContextInfo.
>
> [NSApp beginSheet: alertWindow
> modalForWindow: [selfwindowForSheet]
> modalDelegate: self
> didEndSelector: @selector(didEndSheet:returnCode:contextInfo:)
> contextInfo: theContextInfo];
>
>
> and here is the code that runs eventually after the sheet has been dismissed:
>
> - (void)didEndSheet:(NSWindow *)sheet returnCode:(int)returnCode
> contextInfo:(void *)contextInfo
> {
>
> NSLog(@"Sheet End");
> NSLog(@"%@", [contextInfo class]);
> [sheet orderOut:self];
> }
>
>
> The contextinfo's class is logged as NSConcreteMutableData. How can I get
> back to the array? Why is contextinfo considered to be of class void in the
> signature?
NSArray *theOriginalArray = (NSArray *)contextInfo.
contextInfo is a void * to make it possible to pass in anything you like. You
just have to cast it back to whatever it was when you passed it in in your
other method. By the way, It's also not "of class void". Void is not a class at
all, and calling class on a void * is meaningless - at this point, you're the
only one who knows what class contextInfo should be interpreted as (if it's a
class, which it doesn't have to be).
Best,
Hank
_______________________________________________
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]