• 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
Using NSBundle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using NSBundle


  • Subject: Using NSBundle
  • From: Graham J Lee <email@hidden>
  • Date: Sat, 19 Nov 2005 11:20:36 +0000

Hi,

I'm trying to write a toy screensaver in order to learn things about drawing images and the like. However, I don't seem to be able to load my image :-(. I'm doing this in -startAnimation

- (void)startAnimation
{
[super startAnimation];
[theImage initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"oxford-physics-apple" ofType:@"png"]];
[theImage setSize:aSize];
}

the file "oxford-physics-apple.png" is in the Resources folder in Xcode, and gets copied to Contents/Resources/ in the .saver bundle. However, I've got a line in -drawRect: which logs if theImage==nil and this always seems to be hit - and hence the image isn't drawn to the screen.


If I understand the docs correctly, then Contents/Resources/ is the default directory in which pathForResource:ofType: should look, so I don't have a need to be using pathForResource:ofType:inDirectory: and as the screen saver only has one bundle, then [NSBundle mainBundle] ought to return the right bundle. Is that not true?

Thanks,

Graham.
--
Graham Lee                       GPG Key ID: 01D5B9D8
UNIX Systems Manager,
Oxford Physics Practical Course
http://users.ox.ac.uk/~wadh1342/               01865 273450


_______________________________________________ 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
  • Follow-Ups:
    • Re: Using NSBundle
      • From: Sherm Pendley <email@hidden>
    • or Using NSImage... [was: Re: Using NSBundle]
      • From: Graham J Lee <email@hidden>
  • Prev by Date: Modal dialog weirdness
  • Next by Date: Re: Modal dialog weirdness
  • Previous by thread: Re: Modal dialog weirdness
  • Next by thread: or Using NSImage... [was: Re: Using NSBundle]
  • Index(es):
    • Date
    • Thread