• 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: Question about opening file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about opening file


  • Subject: Re: Question about opening file
  • From: Chris Gehlker <email@hidden>
  • Date: Sun, 07 Oct 2001 21:36:35 -0700

On 10/7/01 8:45 PM, "John Tsombakos" <email@hidden> wrote:

> I'm playing around with a sample application that I built, using
> instructions I found on the web (somewhere, I can't for the life of me
> remember where!) It's a document based application that just has an
> NSImageView in the window. You can open an image and it gets displayed
> in the window. Simple enough.
>
> The tutorial told how to set up the files extensions in the targets pane
> of the project to include jpg files. Today, I tried changing it to be
> able to also open tiff files. I tried adding another file type and
> rebuilt and ran. It would not let me select a tiff file in the Open
> dialog. I tried removing the jpg selection and rebuilding. I even did a
> clean and rebuild but could not open a tiff file. I decided to try
> changing it back to jpg and cleaned and rebuilt. Now I can't open either
> tiff or jpg!

Here is a little code fragment that will open any kind of picture. Sorry
about the formatting:

NSOpenPanel *oPanel = [NSOpenPanel openPanel];
result = [oPanel runModalForDirectory:[NSHomeDirectory()
stringByAppendingPathComponent:@"Pictures"]
file:nil types:[NSImage imageFileTypes]];

if (result == NSOKButton) {
myImage = [[NSImage alloc] initByReferencingFile:[oPanel filename]];
...


The trick here is [NSImage imageFileTypes] which returns an NSArray of every
type that QuickTime understands, or may understand in the future. It rocks.
--
Many individuals have, like uncut diamonds, shining qualities beneath a
rough exterior. - Juvenal, poet (c. 60-140)


References: 
 >Question about opening file (From: John Tsombakos <email@hidden>)

  • Prev by Date: Thank you
  • Next by Date: Re: Cocoa newbie frustration
  • Previous by thread: Question about opening file
  • Next by thread: Re: Question about opening file
  • Index(es):
    • Date
    • Thread