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