1

我有一个网址,我知道它将把我重定向到另一个目的地:

url = [NSString stringWithFormat:@"http://graph.facebook.com/%d/picture?type=normal", profile_id];

在这种情况下,http ://profile.ak.fbcdn.net/static-ak/rsrc.php/v1/yh/r/C5yt7Cqf3zU.jpg

我如何获得第二个 url 知道第一个?

4

1 回答 1

2

您可以通过以下代码找到:

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {

    // cast the response to NSHTTPURLResponse so we can look for 404 etc
    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
    NSURL *url = [httpResponse URL];

    if ([httpResponse statusCode] >= 400) {
        // do error handling here
        NSLog(@"remote url returned error %d %@",[httpResponse statusCode],[NSHTTPURLResponse localizedStringForStatusCode:[httpResponse statusCode]]);
    } else {
        // start recieving data
    }
}

谢谢。

于 2013-06-28T11:49:23.040 回答