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

Re: NSURL question


  • Subject: Re: NSURL question
  • From: Richard Schreyer <email@hidden>
  • Date: Wed, 22 Aug 2001 21:42:56 -0700

On Wednesday, August 22, 2001, at 09:08 PM, Yuhui wrote:

Hi

I've had some success with my first Cocoa program, but I need help with NSURL. Basically, my code gets a URL string (with http:// and everything), then retrieves the resource into a string. Here's my code:

data = [NSMutableString stringWithContentsOfURL:@"http://www.apple.com/";];

I'm not sure if this is related to your problem or not (or if you already know this, but it's some kind of abbreviation of your code), but that method wants a NSURL, and your giving it a NSString. They two are different beasts.

What this should look like is:

url = [NSURL urlWithString:@"http://www.apple.com/";];
data = [NSString stringWithContentsOfURL: url];

I haven't done this myself, but it appears you need to get the NSURLHandle from the URL, and then add the object that needs to be notified with [urlHandle addClient: foo]. The object you specify will need to implement the NSURLHandleClient protocol. If you don't understand protocols, there is lots of good reading on the subject. I would start with Apple's ObjC book.


Richard Schreyer


References: 
 >NSURL question (From: Yuhui <email@hidden>)

  • Prev by Date: Re: Use of performGammaFade in ScreenSavers
  • Next by Date: Re: Help on adding help
  • Previous by thread: NSURL question
  • Next by thread: Use of performGammaFade in ScreenSavers
  • Index(es):
    • Date
    • Thread