• 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
NSOpenPanel Performance the Second Time
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSOpenPanel Performance the Second Time


  • Subject: NSOpenPanel Performance the Second Time
  • From: Thomas Wetmore <email@hidden>
  • Date: Thu, 08 Oct 2009 02:01:52 -0400

I use the following function to show an open panel and get the path to a file. I have inserted three NSLog calls.

This first time I call this function the panel opens immediately and the three log messages follow each other immediately.

The second and every later time I call this function, performance is terrible -- there is about two or three seconds between the first two log messages though the third follows immediately after the second.

The evidence is that [NSOpenPanel openPanel] is the culprit. Is there something I need to do (i.e., close) to the open panel before I return from this function? I tried making the openPanel static and only creating it once, but this caused a crash.

Thanks very much for any advice.

Tom Wetmore


// Use a NSOpenPanel to choose the name of a Gedcom file to read.
//----------------------------------------------------------------------------------------------------------------------
NSString* openFile (NSString* title)
{
NSLog(@"openFile called"); // TODO: Remove.
NSOpenPanel* oPanel = [NSOpenPanel openPanel]; <<<<<------- PERFORMANCE SUFFERS HERE---------<<<<
NSLog(@"back from openening panel"); // TODO: Remove.
[oPanel setCanChooseDirectories: NO];
[oPanel setCanChooseFiles: YES];
[oPanel setCanCreateDirectories: NO];
[oPanel setAllowsMultipleSelection: NO];
[oPanel setAlphaValue: 0.99];
[oPanel setTitle: title];
NSArray* fileTypes = [NSArray arrayWithObjects: @"txt", @"ged", @"gedcom", nil];
[oPanel setAllowedFileTypes: fileTypes];
NSLog(@"about to runModal"); // TODO: Remove
if ([oPanel runModal] != NSOKButton) return @"";

// Return the file name.
NSArray* files = [oPanel filenames];
if ([files count] == 0) return @"";
NSString* filePath = [files objectAtIndex:0];
return filePath;
}


_______________________________________________

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 Performance the Second Time
      • From: Corbin Dunn <email@hidden>
  • Prev by Date: Re: app delegate +initialize
  • Next by Date: NWPickerField a new iPhone control to share.
  • Previous by thread: Re: Active Read/Write of NSTask
  • Next by thread: Re: NSOpenPanel Performance the Second Time
  • Index(es):
    • Date
    • Thread