• 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: Filtering File Names in NSOpenPanel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Filtering File Names in NSOpenPanel


  • Subject: Re: Filtering File Names in NSOpenPanel
  • From: Andy Lee <email@hidden>
  • Date: Thu, 7 Jul 2005 20:52:54 -0400

On Jul 7, 2005, at 3:00 PM, Vince Ackerman wrote:
I need the user to point to and open certain files and they all end in the "xxxxxxxsli.doc", the first part changes from month to month. I guess I could just look at the file name OpenPanel returns and then put up an error message if the user doesn't select the right file.

A delegate method was suggested earlier -- did you look at your options? NSOpenPanel inherits from NSSavePanel, so it uses the same delegate methods. In particular:


panel:shouldShowFilename:

- (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename

Gives the delegate the opportunity to filter out items that it doesn’t want the user to see or choose. The NSSavePanel sender sends this message to the panel’s delegate for each file or directory (filename) it is about to load in the browser. The delegate returns YES if filename should be displayed, and NO if the NSSavePanel should ignore the file or directory.


This sounds like what you want. In your implementation, check whether filename ends with "sli.doc" and return YES if so, NO otherwise. One line of code.


--Andy

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


References: 
 >Filtering File Names in NSOpenPanel (From: Vince Ackerman <email@hidden>)
 >Re: Filtering File Names in NSOpenPanel (From: Charilaos Skiadas <email@hidden>)
 >Re: Filtering File Names in NSOpenPanel (From: Vince Ackerman <email@hidden>)

  • Prev by Date: Calling an Automator workflow from Cocoa?
  • Next by Date: Custom Image Unit/CIFilter troubles
  • Previous by thread: Re: Filtering File Names in NSOpenPanel
  • Next by thread: Sample Cocoa code to show how to launch a doc by sliding its icon into appl icon
  • Index(es):
    • Date
    • Thread