简体   繁体   English

ASIHTTPREQUEST 在 iOS 8.3 中未按预期工作

[英]ASIHTTPREQUEST not working as expected in iOS 8.3

I have used asihttprequest classes in my app for calling web-api.我在我的应用程序中使用了 asihttprequest 类来调用 web-api。

But now it's not working in iOS 8.3 as well as in iOS 11+ and already full app was developed so can't change whole asihttprequest to a.networking so I need some solution in asihttprequest only.但是现在它在 iOS 8.3 和 iOS 11+ 中都不起作用,并且已经开发了完整的应用程序,所以不能将整个asihttprequest更改为a.networking ,所以我只需要asihttprequest中的一些解决方案。

I want to add that when I am calling api using startAsynchronous it's not working but when I am using startSynchronous it's working fine but for a while it freezes the app.我想补充一点,当我使用startAsynchronous调用 api 时它不起作用,但是当我使用startSynchronous时它工作正常但有一段时间它会冻结应用程序。

Once request sent it's not come back with any response not failed or success.一旦发送请求,它不会返回任何失败或成功的响应。

I am using ASIFormDataRequest to call api like this.我正在使用 ASIFormDataRequest 像这样调用 api。

 NSString *stringurl=[NSString stringWithFormat:@"%@%@",kBaseUrl,kForgotPasswordAPI];
    NSString * encodedUrl = [stringurl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]];
    NSURL *url = [NSURL URLWithString:encodedUrl];
    requestForgotPassword = [ASIFormDataRequest requestWithURL:url];
    [requestForgotPassword setRequestMethod:@"POST"];
    [requestForgotPassword setPostValue:@"mobile" forKey:@"environment"];
    [requestForgotPassword setPostValue:txtEmailAddress.text forKey:@"email_address"];
    [requestForgotPassword setTimeOutSeconds:60];
    [requestForgotPassword setDelegate:self];
    [requestForgotPassword startAsynchronous];

Finally I have found the answer as i describe my problem i am facing problem while calling web-Api using ASIHTTPREQUEST.最后我找到了答案,因为我描述了我在使用 ASIHTTPREQUEST 调用 web-Api 时遇到的问题。

Now what i have done to solve that issue is i have change api calling time like first i am calling api in viewDidLoad() but now i have calling api in viewDidAppear() and it's working fine for me.现在我为解决这个问题所做的是改变 api 调用时间,就像我第一次在 viewDidLoad() 中调用 api 但现在我在 viewDidAppear() 中调用 api 并且它对我来说工作正常。

If anyone else facing same problem please try this solution and please don't use this ASIHTTPREQUEST class in next project.如果其他人遇到同样的问题,请尝试此解决方案,请不要在下一个项目中使用此 ASIHTTPREQUEST class。

Thank you.谢谢你。

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

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