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

Re: NSOpenPanel Performance the Second Time


  • Subject: Re: NSOpenPanel Performance the Second Time
  • From: Corbin Dunn <email@hidden>
  • Date: Thu, 08 Oct 2009 08:07:06 -0700

Tom,
Have you used 'Shark' and 'Sample' to figure out why it is slow?

Please log a bug (bugreporter.apple.com) if you believe it is slow due to the framework. Please include any samples/shark results, and ideally a test case.

corbin

On Oct 7, 2009, at 11:01 PM, Thomas Wetmore wrote:

> 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

References: 
 >NSOpenPanel Performance the Second Time (From: Thomas Wetmore <email@hidden>)

  • Prev by Date: Re: Autorelease pool
  • Next by Date: Re: How to ease the burden on the Garbage Collector?
  • Previous by thread: NSOpenPanel Performance the Second Time
  • Next by thread: NWPickerField a new iPhone control to share.
  • Index(es):
    • Date
    • Thread