iOS背景获取和完成块
我正在试图定义这个方法
- (void)backgroundFetchWithCompletion:(void(^)(UIBackgroundFetchResult))completionHandler;
不过,我得到一个错误UIBackgroundFetchResult说没有types的参数列表只是允许的,我按照本教程和本教程 ,这是他们如何定义他们的方法。
在最后执行一些操作后,您必须在列表中调用一个。
Objective-C的
-
completionHandler(UIBackgroundFetchResultNewData);
-
completionHandler(UIBackgroundFetchResultFailed);
-
completionHandler(UIBackgroundFetchResultNoData);
迅速
-
completionHandler(.NewData)
-
completionHandler(.Failed)
-
completionHandler(.NoData)
完整的例子:
Objective-C的
- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { NSLog(@"performFetchWithCompletionHandler"); //Perform some operation completionHandler(UIBackgroundFetchResultNewData); }
迅速
func application(application: UIApplication, performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) { println("performFetchWithCompletionHandler") //Perform some operation completionHandler(.NewData) }
我只是遇到了同样的问题,解决scheme是将其添加到该块定义方法的文件中:
#import "AppDelegate.h"
- 在保持TabBar的同时在AppDelagate中打开ViewController
- 核心数据NSManagedObject没有有效的NSEntityDescription
- 对应用程序开发的build议iOS。 ApplicationDidEnterBackground
- 改变本地,phonegap /cordova内置的iOS应用程序的键盘外观
- 访问XCTestCase类中的应用程序委托对象导致misaligned_stack_error_ swift
- 为什么我得到延迟加载NSBundle MobileCoreServices.framework?
- APPDelegate中的openURL转换错误NSString – > String(Swift和iOS8)
- UIApplicationLaunchOptionsLocalNotificationKey始终为空 – iOS
- 在Swift中从AppDelegate获取ViewController的实例