0

ASIHTTPRequest私の質問は、追加されたをキャンセルしようとするNSOperationQueueと、デリゲートを呼び出して停止しないということは何も起こらないということです。次のコードを使用しました。

[request cancel];

[request clearDelegatesAndCancel];

しかし、機能していないようです。

私のコード:

[operationQueue addOperationWithBlock:^{

    AsyncCallerClass *asyncClass=[[AsyncCallerClass alloc] init];
    DataSet *ds=[[DataSet alloc]init];
    asyncClass.MethodParameters=[[NSMutableDictionary alloc]init];
    asyncClass.req=cusRequest;
    asyncClass.mehtodName=@"testMethod";
    asyncClass.xmlNameSpace=@"http://test.org/";
    asyncClass.xmlURLAddress=@"http://myPC/service.asmx";
    NSMutableData *data;
    data=[asyncClass getDataFromWebService];
    [ds parseXMLWithData:data];

    NSMutableDictionary *Data_Dictionary=[[NSMutableDictionary alloc]initWithDictionary:[ds getRowsForTable:@"DataTable"] ];

    currRow=[Data_Dictionary objectForKey:@"0"];

}];

現在AsyncCallerClassクラスにあります

ASIHTTPRequest *myRequest = [ASIHTTPRequest requestWithURL:url];

[myRequest setRequestMethod:@"POST"];

[myRequest addRequestHeader:@"Content-Type" value:@"text/xml; charset=utf-8"];

[myRequest addRequestHeader:@"SOAPAction" value:self.SOAPActionURL];

NSString *messageLength = [NSString stringWithFormat:@"%d",[sRequest length]];

[myRequest addRequestHeader:@"Content-Length" value:messageLength];

[myRequest appendPostData:[sRequest dataUsingEncoding:NSUTF8StringEncoding]];

[myRequest setDelegate:self];

[myRequest setTimeOutSeconds:120];

[myRequest startSynchronous];

それをキャンセルするには、AsyncCallerClassのメソッドを呼び出します

-(void) cancelMe:(NSOperationQueue*) myQueue  
{

[myRequest cancel];

[myRequest clearDelegatesAndCancel];

}
4

0 に答える 0