简体   繁体   English

我在哪个视图控制器委托方法中请求API?

[英]In which view controller delegate method do i request the api.?

I have been developing a weather application in iOS 8 . 我一直在开发iOS 8中的天气应用程序。 I need to display the parsed JSON when the view displays. 显示视图时,我需要显示已解析的JSON。 I am not sure in which delegate methods do i need to request the api. 我不确定我需要在哪些委托方法中请求api。 i know it should be requested in the background thread. 我知道应该在后台线程中请求它。 which are the delegate methods run on background thread? 在后台线程上运行哪些委托方法?

you can call your api in every where! 您可以在任何地方调用您的api! for example call in : AppDelegate or in initialize viewController . 例如在AppDelegate中或在初始化viewController中调用

but remember : your request is async so if the request going to fail or getting timed out you should handle it or notify toy first View Controller. 但请记住:您的请求是异步的,因此如果请求失败或超时,则应处理该请求或先通知玩具View Controller。

暂无
暂无

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

相关问题 如何使用委托来指示哪个视图控制器行为与初始视图控制器相同? - How do I use the delegate to dictate which view controller behaves as the initial view controller? 如果我有两个实现协议的视图控制器,如何指定我的第三个控制器的委托者? - If I have two view controllers that implements a protocol, how do I specify which my is the delegate for my third controller? 如何从 App Delegate 切换到不同的视图 controller? - How do I switch to a different view controller from the App Delegate? 如何从应用程序委托打开视图 controller? - How do I open a view controller from the app delegate? UIAlertview 委托方法不在子视图控制器中调用 - UIAlertview Delegate Method not calling in Child View Controller 从视图控制器调用应用程序委托方法 - Call app delegate method from view controller 目标视图控制器上的简单委托方法或属性 - Simple delegate method or property on destination view controller 目标C-视图控制器中的调用方法,该方法已位于应用程序委托的导航顶部 - Objective C - Call method in a view controller which is already in top of navigation from app delegate 在表视图委托方法中发出异步请求 - Make async request in table view delegate method 如何从场景委托中调用 function,该委托在视图 controller 中下载 URL? - How can I call a function from scene delegate which downloads an URL in a view controller?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM