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

Re: Error initializing an NSImage


  • Subject: Re: Error initializing an NSImage
  • From: John Timmer <email@hidden>
  • Date: Sat, 01 Mar 2003 09:39:12 -0500

If the image is in your resources folder, the following code works (and is
quite convenient):

image = [NSImage imageNamed:@"newFile "];

Cheers,

John



> 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.
_______________________________________________
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.

References: 
 >Error initializing an NSImage (From: Hisaoki Nishida <email@hidden>)

  • Prev by Date: Prebinding disabled because of TEXT overlap
  • Next by Date: custom cell drawing
  • Previous by thread: Error initializing an NSImage
  • Next by thread: Re: Error initializing an NSImage
  • Index(es):
    • Date
    • Thread