• 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: NSOpenPanel problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSOpenPanel problem


  • Subject: Re: NSOpenPanel problem
  • From: "Jan E. Schotsman" <email@hidden>
  • Date: Mon, 23 Jan 2012 10:41:07 +0100


On Jan 23, 2012, at 5:17 AM, Ken Thomases wrote:

On Jan 22, 2012, at 1:24 PM, Jan E. Schotsman wrote:

Suppose I want to display a modeless choose file dialog with the beginWithCompletionHandler method.
How can I pass some context info to the handler?

Blocks capture whatever local variables you reference within them. If you reference instance variables, they capture "self" and then access the ivars from that. Just use whatever value you want, directly. That's the great thing about blocks.

That's great indeed, but I need the block to work with a method parameter (an NSString object). Do I need to copy the NSString to an ivar?

-method:(NSString *)someString
	{
	(void)(^handler)(NSInteger result)	=	{ <uses someString > };

	[openPanel beginWithCompletionHandler: handler];
	}

I have a related question for the old beginForDirectory method:

if I try to pass on someString in a C struct (contextInfo) then the compiler complains that ARC doesn't like object pointers in C structs.
I could serialize and unserialize the string. Or is there a better way?

Jan E.

_______________________________________________

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


  • Follow-Ups:
    • Re: NSOpenPanel problem
      • From: Conrad Shultz <email@hidden>
References: 
 >NSOpenPanel problem (From: "Jan E. Schotsman" <email@hidden>)
 >Re: NSOpenPanel problem (From: Ken Thomases <email@hidden>)

  • Prev by Date: Changing Album Name property of the audio book track, does not affect the title of Audiobook on iOS5 device.
  • Next by Date: Re: NSOpenPanel problem
  • Previous by thread: Re: NSOpenPanel problem
  • Next by thread: Re: NSOpenPanel problem
  • Index(es):
    • Date
    • Thread