使用委托方法扩展类

时间:2021-01-09 18:10:06

I would like to extend the ASIHTTPRequest class, yes I know it's not being developed anymore, but I have it through out my project and I don't have time to totally replace it yet. My reason for extending it is to provide a list of fail-over hosts.

我想扩展ASIHTTPRequest类,是的,我知道它不再被开发,但是我已经完成了我的项目,我没有时间完全替换它。我扩展它的原因是提供故障转移主机列表。

My question has to do with the ASIHTTPRequest delegate methods, how do I inherit them in my extended class? Do I need to create another protocol?

我的问题与ASIHTTPRequest委托方法有关,我如何在扩展类中继承它们?我需要创建另一个协议吗?

1 个解决方案

#1


1  

I was in the same situation as you about 8 months ago. I decided to bite the bullet and switch to AFNetworking and am sure glad I did. Working with those delegate methods is a pain. To answer your question, you would have to declare your class as a delegate for the methods you want to handle.

大约8个月前,我和你的情况一样。我决定咬紧牙关切换到AFNetworking,我很高兴我做到了。使用这些委托方法很痛苦。要回答您的问题,您必须将您的类声明为要处理的方法的委托。

If you need help switching, check out my NetworkClient class that I wrote to replace all the delegate method stuff in ASI.

如果你需要帮助切换,请查看我编写的NetworkClient类,以替换ASI中的所有委托方法。

#1


1  

I was in the same situation as you about 8 months ago. I decided to bite the bullet and switch to AFNetworking and am sure glad I did. Working with those delegate methods is a pain. To answer your question, you would have to declare your class as a delegate for the methods you want to handle.

大约8个月前,我和你的情况一样。我决定咬紧牙关切换到AFNetworking,我很高兴我做到了。使用这些委托方法很痛苦。要回答您的问题,您必须将您的类声明为要处理的方法的委托。

If you need help switching, check out my NetworkClient class that I wrote to replace all the delegate method stuff in ASI.

如果你需要帮助切换,请查看我编写的NetworkClient类,以替换ASI中的所有委托方法。