Re: shared NSImage from bundle
Re: shared NSImage from bundle
- Subject: Re: shared NSImage from bundle
- From: Torsten Curdt <email@hidden>
- Date: Tue, 11 Mar 2008 11:48:00 +0100
Thanks!! Perfect
On 11.03.2008, at 11:17, Jean-Daniel Dupas wrote:
The method your looking for is
+ (void)initialize { }
Warning: This method can be called more than once (if a subclass
does not override it) so you should do something like this.
@implementation Foo
+ (void)initialize {
if ([Foo class] == self) {
// load your images here.
}
}
...
Le 11 mars 08 à 11:12, Torsten Curdt a écrit :
While I know I can load an image like this
image = [[NSImagealloc] initWithContentsOfFile:
[[NSBundlemainBundle] pathForResource:@"someimage" ofType:@"PNG"]];
all my NSDocument should be OK to share the same instance.
Creating class level singleton accessors seem a little too much
work. Is there a class level init that could be used to fill class
level variables? Forgive me my blasphemy but something along the
lines of...
public class MyDocument extends NSDocument {
private final static NSImage image;
private final static NSImage image2 = ...;
static {
image = ...
}
...
}
How do people usually do this? Sorry, if this turns out to be more
a Objective-C question than a Cocoa question.
cheers
--
Torsten
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
40shadowlab.org
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden