gpt4 book ai didi

iOS 后台获取和完成 block

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:26:27 25 4
gpt4 key购买 nike

我正在尝试定义这个方法

- (void)backgroundFetchWithCompletion:(void(^)(UIBackgroundFetchResult))completionHandler;

但是我在 UIBackgroundFetchResult 上收到一个错误,说只允许没有类型的参数列表,我正在学习本教程和这个 tutorial这就是他们定义方法的方式。

最佳答案

最后执行一些操作后,您必须调用列表中的一个。

objective-C

  1. completionHandler(UIBackgroundFetchResultNewData);
  2. completionHandler(UIBackgroundFetchResultFailed);
  3. completionHandler(UIBackgroundFetchResultNoData);

swift

  1. completionHandler(.NewData)
  2. completionHandler(.Failed)
  3. completionHandler(.NoData)

完整示例:

objective-C

- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
NSLog(@"performFetchWithCompletionHandler");
//Perform some operation
completionHandler(UIBackgroundFetchResultNewData);
}

swift

func application(application: UIApplication, performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
println("performFetchWithCompletionHandler")
//Perform some operation
completionHandler(.NewData)
}

关于iOS 后台获取和完成 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29002203/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com