How to call completeHandler to execute a FetchWithCompletionHandler in Swift

how can I call the completion handler for background fetch in Swift. I do the following:

func application(application: UIApplication, performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) { // Do something completionHandler (UIBackgroundFetchResultNoData) // This does not work :( return } 

Could you help me? Thanks,

Tobi

+5
source share
1 answer

The enumeration case is UIBackgroundFetchResult.NoData , so the correct way is:

 completionHandler (UIBackgroundFetchResult.NoData) 

or even:

 completionHandler (.NoData) 

because the type can be inferred from the closure signature

Hint: if you are not sure about the function signature or enumerations, etc., enter the type in Xcode, in this case UIBackgroundFetchResult , then cmd + click on it to go to the definition, or click + on the pop-up window of its declaration. This usually helps.

+6
source

Source: https://habr.com/ru/post/1206667/


All Articles