开发者

Does NSURLConnection choose its delegate automatically?

Does NSURLConnection automatically send messag开发者_开发知识库es to the class that initialized it or how does it work because I did not reference it in my header file.


No, you need to specify the delegate, as in this example from the URL Loading System Guide

// Create the request.
NSURLRequest *theRequest=[NSURLRequest 
                        requestWithURL:[NSURL URLWithString:@"http://www.apple.com/"]
                        cachePolicy:NSURLRequestUseProtocolCachePolicy
                    timeoutInterval:60.0];
// create the connection with the request
// and start loading the data
NSURLConnection *theConnection=[[NSURLConnection alloc] 
                                 initWithRequest:theRequest delegate:self];

(note the delegate:self part).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜