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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/devlists%40shadowlab.org

This email sent to [EMAIL PROTECTED]


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to