Using NSBundle
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