NSOPeration内でバックグラウンドモードの非同期NSURLConnectionを使用する必要があります。これは、応答に大きなデータがあるためです。didEnterBackgroundで使用するAppleの有限長コーディングを回避する必要があります。代わりに、NSInvocationを使用してNSOperationを介して次のコードを使用しますが、機能しません。 connectToServerはNSURLConnection操作を行っています。助けてください?didReceiveData、didReceiveResponseデリゲートメソッドが呼び出されていませんか?
-(void)viewDidLoad
{
NSOperationQueue *queue = [NSOperationQueue new];
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self
selector:@selector(connectServer)
object:nil];
[queue addOperation:operation];
[operation release];
[queue autorelease];
}
-(void)connectServer
{
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");
}
}
}