• 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
Error initializing an NSImage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Error initializing an NSImage


  • Subject: Error initializing an NSImage
  • From: Hisaoki Nishida <email@hidden>
  • Date: Sat, 1 Mar 2003 05:42:14 -0500

I am trying to initialize an image, that's all I'm doing.
But for some reason it fails, my NSAssert saying that filePath is nil.
The bundle printed in NSLog as "NSBundle
</Users/hisaokin/Desktop/MyApp/build/MyApp.app> (loaded)"
newFile is valid. It's the name of the file without the extension, and
it exists in a folder called Resources in my project folder. The
extension is ".tiff". I tried with many TIFF images, same result. How
could the filePath be nil? it's really puzzling me.

Here's the code:

NSBundle * mainBundle = [NSBundle mainBundle];
NSString * filePath = [mainBundle pathForResource:newFile
ofType:@"tiff"];
NSImage * image = [[[NSImage alloc]
initWithContentsOfFile:[filePath stringByExpandingTildeInPath]]
autorelease];


Rather simple..

Any help appreciated!


Thanks,


-yuki
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Error initializing an NSImage
      • From: John Timmer <email@hidden>
  • Prev by Date: Rendezvous problem
  • Next by Date: setImage & setAlternateImage
  • Previous by thread: Rendezvous problem
  • Next by thread: Re: Error initializing an NSImage
  • Index(es):
    • Date
    • Thread