• 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: Steve Christensen <email@hidden>
  • Date: Sun, 30 Aug 2009 15:17:52 -0700

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.

Attachment: PGP.sig
Description: PGP signature

 _______________________________________________
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

  • Follow-Ups:
    • Re: NSOpenpanel in Snow Leopard
      • From: Charlie Dickman <email@hidden>
References: 
 >NSOpenpanel in Snow Leopard (From: Charlie Dickman <email@hidden>)

  • Prev by Date: Re: Find/replace in selected text in 3.2 ?
  • Next by Date: Show-stopper Xcode hang in Snow Leopard
  • Previous by thread: NSOpenpanel in Snow Leopard
  • Next by thread: Re: NSOpenpanel in Snow Leopard
  • Index(es):
    • Date
    • Thread