• 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: shared NSImage from bundle
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: shared NSImage from bundle
      • From: Jim Puls <email@hidden>
References: 
 >shared NSImage from bundle (From: Torsten Curdt <email@hidden>)
 >Re: shared NSImage from bundle (From: Jean-Daniel Dupas <email@hidden>)

  • Prev by Date: Re: Quit application when window closes
  • Next by Date: Pragmatic use of private framework class (in this case OSADictionary)
  • Previous by thread: Re: shared NSImage from bundle
  • Next by thread: Re: shared NSImage from bundle
  • Index(es):
    • Date
    • Thread