Re: NSURL question
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