応答に多くのデータがあるため、バックグラウンドモードで実行したいと思いNSURLConnection
ます。フォーラムでは、で使用するためにAppleの有限長コーディングを使用するように指示されていますdidEnterBackground
。しかし、私はそれを避けたいと思います。その代わりに、次のコードをNSOperation
asNSInvocation
で使用しますが、機能していません。connectToServer
操作中ですNSURLConnection
。助けてください。didReceiveData
、didReceiveResponse
デリゲートメソッドは呼び出されませんか?
NSOperationQueue *queue = [NSOperationQueue new];
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self
selector:@selector(connectToServer)
object:nil];
[queue addOperation:operation];
[operation release];
[queue autorelease];
-(void)connectToServer
{
NSURL *url = [NSURL URLWithString:@"http://www.google.com"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSURLConnection *theConnection = [[[NSURLConnection alloc] initWithRequest:theRequest delegate:self] autorelease];
if( theConnection )
{
webData = [[NSMutableData data] retain];
}
else
{
NSLog(@"theConnection is NULL");
}
}