• 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: Weird problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Weird problem


  • Subject: Re: Weird problem
  • From: Dan Wood <email@hidden>
  • Date: Mon, 15 Oct 2001 10:52:17 -0700

This sounds similar to another problem that just appeared on one of these lists a few days ago. Some URL-loading methods *only* seem to work with file:// URLS and not network based URLs like http://. I haven't seen a definitive list of what works and what doesn't, but I believe you have stumbled on the fact that NSData works, but NSImage doesn't.

The safest way I've seen is to actually get the data with NSURL or NSURLHandle, e.g. [NSURL resourceDataUsingCache:]. By using NSURLHandle, you're even better off, because you can cause your load to take place in the background.

Dan


On Sunday, October 14, 2001, at 10:31 PM, Jeff LaMarche wrote:

Wonder if anyone might have some thoughts on this. I did this:

thumb = [[NSImage alloc] initWithContentsOfURL: thumbURL];

thumbURL is a valid URL to a JPEG image, however thumb ends up null.

Now, if I do this:

NSData *data;
data = [NSData dataWithContentsOfURL:thumbURL];
thumb = [[NSImage alloc] initWithData:data];

It works just dandy. Nothing else changed anywhere else, I just loaded
the image data to an NSData object and used that instead of the original
URL to load the image. Is there something wrong with the way I attempted
to load the image from a URL?
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev



--
Dan Wood
email@hidden
http://www.karelia.com/
http://www.bikealameda.org/
Mac OS X Developer: Online Resume: http://www.karelia.com/resume.html


References: 
 >Weird problem (From: Jeff LaMarche <email@hidden>)

  • Prev by Date: Re: Q's about Obj-C
  • Next by Date: Re: Q's about Obj-C
  • Previous by thread: Weird problem
  • Next by thread: Getting mount structure and inode
  • Index(es):
    • Date
    • Thread