Webkit Help

I’ve been playing with the ‘MiniBrowser’ which is in the Developer examples, but have one problem which I can’t resolve. I’m trying to download a zipped file from a website but nothing happens.

I’ve tried the following code but still nothing happens

// Starts download

  • (void)download
    {
    NSURL *myURL = [NSURL URLWithString:@“http://www.apple.com/”];
    [myURL loadResourceDataNotifyingClient:self usingCache:YES];
    }

// This method will be called when the download has finished

  • (void)URLResourceDidFinishLoading:(NSURL *)sender
    {
    NSData *urlContents = [sender resourceDataUsingCache:YES];

    if ([urlContents writeToFile:[@“~/Documents/applewebsite.html”
    stringByExpandingTildeInPath]
    atomically:YES])
    {
    // It was successful, do stuff here
    } else {
    // There was a problem writing the file
    }
    }

Any help would be great…

PaulB

  1. This is a question to pose to the cocoa-dev mailing list. See lists.apple.com.

  2. I had no problem with retrieving the URL data with the code exactly as you posted above. How are you calling it?