使用GCD执行sudzc Web服务 [英] Performning sudzc webservice using GCD

查看:85
本文介绍了使用GCD执行sudzc Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对GCD有点困惑

我尝试对执行我的Web服务调用的类进行计算:

I try caling a class where my webservice call is executed:

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        [searchService doSearch:self.searchData];
});

我正在使用Sudzc生成的Web服务.以下是对Sudzc生成的服务以及SearchService类内部的实际服务调用:

I'm using Sudzc-generated webservice. The actual service call to the service generated with Sudzc and is inside the SearchService class is the following:

 [service doSearch:self action:@selector(doSearchHandler:) e: searchArgs];

通话结束后,我应该返回:

Once the call is done I should return to:

- (void) doSearchHandler: (id) value {
}

不使用GCD就能正常工作,但是当我添加GCD时,我再也不会返回doSearchHandler方法.

Without using the GCD it works fine, but when I add it, I never return to the doSearchHandler method.

推荐答案

我遇到Sudzc操作阻塞主线程的问题. 但是,Soap请求不是问题,因为尽管NSURLRequest在主线程上执行,但其数据由委托didReceiveData

I had the problem of the Sudzc operation blocking the main thread. However, the Soap request is not the problem as, although the NSURLRequest is executed on the main thread, its data is managed by the delegate didReceiveData

阻止我的UI的是处理在Handler方法中发生的接收到的XML.

What was blocking my UI was the processing of the received XML that happened in the Handler method.

在处理程序方法(- (void) SudzcRequestHandler: (id) value { ...)中,我像这样处理数据:

In the handler method (- (void) SudzcRequestHandler: (id) value { ...) I process the data like this:

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

...processing...

[[NSNotificationCenter defaultCenter] postNotificationName:KManagerHasFinishedLoading object:self userInfo:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:NOTIFICATION_RESULT_OK], @"Result", nil]];

});

我在Manager中运行处理,Manager是一个单例对象,但是其他实现可能会有所不同.因此,该通知用于让我的ViewController知道处理已结束.

I run the processing in Manager, which is a singleton object, but other implementations may vary. So the notification is used to let my ViewController know that processing has ended.

这篇关于使用GCD执行sudzc Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆