• 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
NSImage lazy initialization
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSImage lazy initialization


  • Subject: NSImage lazy initialization
  • From: Mark Rowe <email@hidden>
  • Date: Fri, 31 Jan 2003 20:18:16 +1300

Hello,

The documentation for NSImage's initByReferencingURL: says

Initializes the receiver, a newly allocated NSImage instance, for the file at url. This method initializes lazily: The NSImage doesn't actually open url or create image representations from its data until an application attempts to composite or requests information about the NSImage.

From this I infer that the image data is not downloaded from the Internet until a method that requires it be present is called. In reality, this does not seem to be the case. The code below is what I am using to try this. The program blocks on the call to initByReferencingURL until the image data has been retrieved. Does anyone have some advice on this matter?

- (id) init
{
NSLog(@"-[Test init]");
if (![super init])
return nil;
_img = [[NSImage alloc] initByReferencingURL:[NSURL URLWithString:@"http://www.megatokyo.com/strips/0101.gif";]];
[_img setDelegate:self];
return self;
}


Mark Rowe
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Determining if a NSTextField is selected....
  • Next by Date: Re: Adding design-time 'live' functionality to IB palette items
  • Previous by thread: Problems making an app Apple-scriptable
  • Next by thread: rendering 256 color image in NSBitmapImageRep
  • Index(es):
    • Date
    • Thread