• 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 in Snow Leopard
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSOpenpanel in Snow Leopard


  • Subject: Re: NSOpenpanel in Snow Leopard
  • From: Charlie Dickman <email@hidden>
  • Date: Sun, 30 Aug 2009 18:55:45 -0400

Steve,

Thanks for the suggestion. It made me have another look at the code and that line is not necessary as it was for debugging so that I could easily see the filename that was selected while debugging.

I've changed the code to look like this...

NSArray *filesToOpen, *fileTypes = [NSArray arrayWithObject: @"txt"];
NSOpenPanel *oPanel = [NSOpenPanel openPanel];
NSString *fileToOpen;
[oPanel setAllowsMultipleSelection: NO];
[oPanel setResolvesAliases: YES];
[oPanel setTitle: @"IOSilver script file"];


if ([oPanel runModalForTypes: fileTypes] == NSOKButton) {
filesToOpen = [oPanel filenames];
fileToOpen = [filesToOpen objectAtIndex: 0];
[self constructScriptFromFileNamed: fileToOpen];
}

with the same sort of address exception still happening at a later time in the run loop. Also, when debugging the open panel dialog is very slow to come up and waiting for the file list to show is interminable.

On Aug 30, 2009, at 6:17 PM, Steve Christensen wrote:

I'd say your most likely point of failure is in using the result of -[NSString cStringUsingEncoding:]. Both the declaration in NSString.h as well as the documentation for that method list a number of caveats including a possible buffer deallocation in some cases. A safer method would be -[NSString getCString:maxLength:encoding:] since you control when the buffer is deallocated.

steve


On Aug 30, 2009, at 2:00 PM, Charlie Dickman wrote:

Greetings,

When debugging in Xcode 3.2 (Snow Leopard) the following code "works" but, sometime later, causes addressing exception in the apps run loop...

NSArray *filesToOpen, *fileTypes = [NSArray arrayWithObject: @"txt"];
NSOpenPanel *oPanel = [NSOpenPanel openPanel];
NSString *fileToOpen;
const char *fileToRead = NULL;
[oPanel setAllowsMultipleSelection: NO];
[oPanel setResolvesAliases: YES];
[oPanel setTitle: @"IOSilver script file"];

if ([oPanel runModalForTypes: fileTypes] == NSOKButton) {
filesToOpen = [oPanel filenames];
fileToOpen = [filesToOpen objectAtIndex: 0];
fileToRead = [fileToOpen cStringUsingEncoding: NSASCIIStringEncoding];
[self constructScriptFromFileNamed: fileToOpen];
}

Further, when used without the debugger it causes all sorts of strange results regarding subsequent events such as keypresses.

Any comments or ideas as to what's up would be greatly appeciated.


Charlie Dickman
email@hidden



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >NSOpenpanel in Snow Leopard (From: Charlie Dickman <email@hidden>)
 >Re: NSOpenpanel in Snow Leopard (From: Steve Christensen <email@hidden>)

  • Prev by Date: Show-stopper Xcode hang in Snow Leopard
  • Next by Date: Re: Show-stopper Xcode hang in Snow Leopard
  • Previous by thread: Re: NSOpenpanel in Snow Leopard
  • Next by thread: Re: NSOpenpanel in Snow Leopard
  • Index(es):
    • Date
    • Thread