0

我正在使用此代码片段http://snipplr.com/view/43115/,我想知道如何访问标签属性以对 connectionDidFinishLoading 中的数据执行不同的操作?

4

1 回答 1

1

是的,但是该方法的参数是 URLConnection 类型,而不是 CustomURLConnection。如果您知道该对象实际上是一个 CustomURLConnection,您可以重新转换它并提取“tag”属性:

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
    CustomURLConnection *myconn = (CustomURLConnection *)connection;
    NSLog(@"%@", myconn.tag);

    NSMutableData *dataForConnection = [self dataForConnection:(CustomURLConnection*)connection];
    [connection release];

    // Do something with the dataForConnection.
}
于 2012-04-27T15:54:41.060 回答