繁体   English   中英

Web服务呼叫冻结iPad应用程序

[英]Webservice call freezing ipad app

我有一个应用程序,我试图在其中使用asihttp调用网络服务。 一切正常,但问题是在完成呼叫后进行中的服务呼叫中,所有操作按钮均无法正常工作。 下面是我的代码

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:strURL]];
    [request setAuthenticationScheme:(NSString *)kCFHTTPAuthenticationSchemeBasic];
    [request setUsername:usrname];
    [request setPassword:passwrd];
    [request setRequestMethod:@"GET"];
    [request setDelegate:self];
    [request setDownloadDestinationPath:JsonPath];
    [request startAsynchronous];

我已经测试了同步和异步但都存在相同的问题。

在后台线程中调用下载方法。

一旦下载完成,请在主线程上调用updateUI方法。

据我所知,ASIHTTP在主线程中调用其方法。 您可以在此处使用AFNetWorking以获得更快的响应

像这样使用Grand Central Dispatch(GCD)

dispatch_queue_t jsonParsingQueue = dispatch_queue_create("jsonParsingQueue", NULL);


    dispatch_async(jsonParsingQueue, ^{
        @try {
             //call webservise code
       }
 }
        @catch (NSException * e) {
            NSLog(@"Exception: %@", e);


        }
        dispatch_async(dispatch_get_main_queue(), ^{


            //table reload or other code

        });
    });

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM