• 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 may not respond to setDirectoryURL?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSOpenPanel may not respond to setDirectoryURL?


  • Subject: Re: NSOpenPanel may not respond to setDirectoryURL?
  • From: Howard Moon <email@hidden>
  • Date: Thu, 08 Mar 2012 11:04:11 -0800

On Mar 8, 2012, at 10:10 AM, Howard Moon wrote:

>
> On Mar 8, 2012, at 9:17 AM, Mike Abdullah wrote:
>
>>
>> On 8 Mar 2012, at 14:54, Howard Moon wrote:
>>
>>> On Mar 8, 2012, at 6:21 AM, Mike Abdullah wrote:
>>>>>
>>>>> 	I'm really not that familiar with Objective-C and Cocoa yet, but I'm getting a warning for something that works fine, and I hate warnings.  The warning is:
>>>>>
>>>>> 		'NSOpenPanel' may not respond to '-setDirectoryURL:'
>>>>>
>>>>> 	I know that setDirectoryURL: is an NSSavePanel message, but NSOpenPanel derives from NSSavePanel, so why does it give me this warning?  As I said, it works fine (i.e., the open panel starts out in the folder I specified).  Is there a case where it WON'T work?  If not, then is there a way to prevent the warning?
>>>>
>>>> That method was introduced in 10.6. Are you perhaps building against the 10.5 SDK or even earlier?
>>>>
>>>
>>> Ah, yes, that's it.  But I do need to support 10.5.  What can I use that works in 10.5 thru 10.7?
>>
>> Options:
>>
>> A)
>> Bump the SDK setting to 10.6, keeping the deployment target at 10.5. Don't call any 10.6-only methods when running on 10.5. (i.e. check -respondsToSelector: or similar)
>>
>> B)
>> Declare the new methods as categories in headers, but don't actually implement the methods. That will tell the compiler how to call those new methods. Once again, don't call 10.6-only methods while running on 10.5
>>
>> C)
>> Fallback to older, deprecated APIs. e.g. -directory
>>
>
>
> Hmmm... I'm building a VST3/vstgui4 plug-in, and I think the base SDK and deployment targets are set as required, like this:
>
> SDKROOT = macosx10.5
> SDKROOT[arch=x86_64] = $(DEVELOPER_SDK_DIR)/MacOSX10.6.sdk
>
> When I build either a 32-bit or 64-bit build, while running on 10.6, it executes -setDirectoryURL with no problems.  I haven't tried running in 10.5 yet.
>
> Can I keep my above settings, but do this?
>
> 	if ([openPanel respondsToSelector:@selector(setDirectory)])
> 		[openPanel setDirectory:nsParentPath];
> 	else
> 	{
> 		NSURL*	nsParentURL		= [NSURL fileURLWithPath:nsParentPath isDirectory:YES];
> 		[openPanel setDirectoryURL:nsParentURL];
> 		//[nsParentURL release]; // No...crashes! must be used by panel
> 	}


That code works in either 32-bit or 64-bit under 10.6, but it seems to be throwing an exception or something on 10.5(.8), because when I execute it, no dialog appears and I can continue along with other work in my plug-in, as if nothing had happened.  (This is all executed from a button press in a sheet.)

I need to be able to set the default directory in whatever OS I'm in, whether it's 10.5, 10.6 or 10.7.  Will option B above allow that?  (I'm not sure what that actually means... I'll have to look up categories, I guess.  But any hint would be appreciated.)

-Howard





_______________________________________________

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 may not respond to setDirectoryURL?
      • From: Howard Moon <email@hidden>
References: 
 >NSOpenPanel may not respond to setDirectoryURL? (From: Howard Moon <email@hidden>)
 >Re: NSOpenPanel may not respond to setDirectoryURL? (From: Mike Abdullah <email@hidden>)
 >Re: NSOpenPanel may not respond to setDirectoryURL? (From: Howard Moon <email@hidden>)
 >Re: NSOpenPanel may not respond to setDirectoryURL? (From: Mike Abdullah <email@hidden>)
 >Re: NSOpenPanel may not respond to setDirectoryURL? (From: Howard Moon <email@hidden>)

  • Prev by Date: Re: Accessing array in thread safe way
  • Next by Date: Re: NSOpenPanel may not respond to setDirectoryURL?
  • Previous by thread: Re: NSOpenPanel may not respond to setDirectoryURL?
  • Next by thread: Re: NSOpenPanel may not respond to setDirectoryURL?
  • Index(es):
    • Date
    • Thread