• 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 file types & wildcards
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSOpenPanel file types & wildcards


  • Subject: Re: NSOpenPanel file types & wildcards
  • From: Tan Dung Ho <email@hidden>
  • Date: Thu, 20 Jan 2005 16:40:50 +0700

Hi,
You can try as follow:

  int result;
 NSArray* fileTypes = [NSArray  arrayWithObjects: @"ab1", @'ab2", nil];
 // this code only open file *.ab1 and *.ab2
// you can add others
    NSOpenPanel *oPanel = [NSOpenPanel openPanel];

    result = [oPanel runModalForDirectory:NSHomeDirectory() file:nil
types:fileTypes];
    //
    if (result == NSOKButton) {
          // work work
        }
    }

You can open file types (e.g text file, GIf file) , simply change the line


NSArray* fileType =  [NSArray  arrayWithObjects: @"ab1", @'ab2", nil];

in the above example to something like this:

NSArray* fileTypes = [NSArray
arrayWithObjects:NSFileTypeForHFSTypeCode('TEXT'),NSFileTypeForHFSTypeCode('GIFF),
nil];

Read 'NSFileTypeForHFSTypeCode' for more information

if you know other ways, tell me. :)

best reguard.


On Wed, 19 Jan 2005 12:13:36 -0600, Glen Simmons
<email@hidden> wrote:
> Is it possible to use wildcards in the file types passed to
> NSOpenPanel's -beginSheetForDirectory:file:types:modalForWindow: ...
> method? i.e., I want to open files with an extension of ab1, ab2, abc,
> abx, etc., so I'd like to pass something like @"ab*" or @"ab?" but
> those don't seem to work.
>
> Thanks,
> Glen
>
>  _______________________________________________
> 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
>
 _______________________________________________
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: 
 >NSOpenPanel file types & wildcards (From: Glen Simmons <email@hidden>)

  • Prev by Date: Re: Converting sound
  • Next by Date: Re: Hex <=> NSNumber?
  • Previous by thread: NSOpenPanel file types & wildcards
  • Next by thread: Finding out my document's extension
  • Index(es):
    • Date
    • Thread