ios 7推送通知didReceiveRemoteNotification方法运行在UI线程还是单独的线程上? [英] ios 7 Push Notification didReceiveRemoteNotification method run on UI thread or separate thread?

查看:117
本文介绍了ios 7推送通知didReceiveRemoteNotification方法运行在UI线程还是单独的线程上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler方法是在UI线程上运行还是在单独的后台线程上运行?因为我需要基于推送消息处理数据并使用Core Data将其存储在本地数据库表中.如果我用这种方法执行Core Data操作,是否会干扰UI?

(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler method run on UI Thread or separate background thread? Because I need to process data based on push message and store in local database table using Core Data. If I do Core Data operations in this method,it will disturb the UI or not?

推荐答案

应用程序(_:didReceiveRemoteNotification:fetchCompletionHandler :) UIKit 的一部分到UI线程:

application(_:didReceiveRemoteNotification:fetchCompletionHandler:) is part of UIKit, which is tied to the UI thread:

除非另有说明,否则仅从应用程序的主线程或主调度队列中使用UIKit类.此限制尤其适用于从UIResponder派生的类,或涉及以任何方式操纵应用程序的用户界面的类.

Use UIKit classes only from your app’s main thread or main dispatch queue, unless otherwise indicated. This restriction particularly applies to classes derived from UIResponder or that involve manipulating your app’s user interface in any way.

UIKit通过从UI线程调用此方法来遵循其自身的规则.这样可以轻松使用其他UIKey方法,但是您有责任确保您的方法能够快速返回.

UIKit follows its own rules by calling this method from the UI thread. This makes it easy to use other UIKey methods, but you are responsible for ensuring that your method returns quickly.

这篇关于ios 7推送通知didReceiveRemoteNotification方法运行在UI线程还是单独的线程上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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