• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: (void *)contextInfo
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (void *)contextInfo


  • Subject: Re: (void *)contextInfo
  • From: "Hank Heijink (Mailinglists)" <email@hidden>
  • Date: Tue, 12 Jan 2010 15:15:44 -0500

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@hidden)

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:

This email sent to email@hidden

References: 
 >(void *)contextInfo (From: Rainer Standke <email@hidden>)

  • Prev by Date: Re: (void *)contextInfo
  • Next by Date: Snapshotting hidden UIViews
  • Previous by thread: Re: (void *)contextInfo
  • Next by thread: Re: (void *)contextInfo
  • Index(es):
    • Date
    • Thread