Questions tagged [completion-block]

54 questions
28
votes
5 answers

Stop an auto-reverse / infinite-repeat UIView animation with a BOOL / completion block

I'm setting up the following UIView animateWithDuration: method, with the intention of setting my animationOn BOOL elsewhere in the program to cancel that infinite looped repeat. I was under the impression that the completion block would be called…
Luke
  • 9,512
  • 15
  • 82
  • 146
8
votes
1 answer

ios 8 completion block not called

In my app I am using TTOpenInAppActivity to insert "Open in" action inside UIActivityController. Inside it works like this: Some view controller presents UIActivityController with TTOpenInActivity already built in. -(void)openWithAction { NSURL…
6
votes
3 answers

User interaction with uiview and animation completion blocks

I have the following code: [UIView animateWithDuration:2.0 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction animations:^{ imageView.bounds = endBounds; } completion:^(BOOL finished) { [UIView…
Justin Miller
  • 757
  • 2
  • 8
  • 19
5
votes
2 answers

Swift presentViewController completion block working only in debug not called in release

I have a strange behaviour with a completion block in Debug and Release. For example: sourceViewController.presentViewController(ccVC, animated: true, completion: { () -> Void in …
Andrea Bozza
  • 1,374
  • 2
  • 12
  • 31
4
votes
3 answers

How to have a completion handler/block after Alamofire Post request?

I have a method which handles a Apple Push Notification Service remote notification. When this method is executed, I want it to call my server and do a HTTP POST request using the Alamofire library. I want to execute another method that will handle…
The Nomad
  • 7,155
  • 14
  • 65
  • 100
4
votes
1 answer

How do I use a completionBlock in swift?

I'm trying to utilize swift's SKStoreProductViewController, but am getting errors with my syntax, specifically with my completion block. Here is my code: let storeViewController:SKStoreProductViewController =…
krisacorn
  • 831
  • 2
  • 13
  • 23
4
votes
1 answer

NSOperation completionBlock is called twice

I'm working on a NSOperation subclass and I came across this very weird issue were the completion block is called twice in a row. The KVO calls seem fine but the completionBlock is still strangely called twice. Am I misunderstanding NSOperation? The…
JonasG
  • 9,274
  • 12
  • 59
  • 88
3
votes
3 answers

swift 4.2 Cannot convert value of type '(_) -> Void' to expected argument type '(() -> Void)?'

==> swift 3 version in perfect work but swift 4 and swift 4.2 in now working. static func animate(_ duration: TimeInterval, animations: (() -> Void)!, delay: TimeInterval = 0, options:…
Digvijaysinh Gida
  • 381
  • 1
  • 7
  • 20
3
votes
2 answers

Using Obj-C completion block in Swift

In Objective-C, I have a completion block class defined as: File.h typedef void (^MYCompletionBlock)(BOOL success, NSDictionary *result, NSError *error); Then, in a Swift file, I try to use the completion block as follows: Swift.swift class…
Vee
  • 1,821
  • 3
  • 36
  • 60
3
votes
1 answer

CKModifyRecordsOperation completion Swift 2.0

I have the code below but I am shown an error when building with Xcode 7 and Swift 2.0 The error is Cannot call value non-function type (([CKRecord]?, [CKRecordID]?, NSError?) -> Void)? Thanks let saveRecordsOperation =…
Tom Coomer
  • 6,227
  • 12
  • 45
  • 82
2
votes
1 answer

Swift Async With Completion Block

I have two functions that executes async. I tried to "syncronize" them with: DispatchGroup and DispatchQueue let queue = DispatchQueue(label: "com.company.app.queue", attributes: .concurrent) let group = DispatchGroup() queue.async(group: group) { …
2
votes
1 answer

Completion block never gets called?

We have a function that when it finishes another function should be called in it's completion block but whatever is inside the completion block is never called. Here is the function: func appendAllData (completion: () -> Void) { guard let…
SwiftyJD
  • 5,257
  • 7
  • 41
  • 92
2
votes
2 answers

How to perform another method after finishing a method using completion block in objective c?

I have two methods. I want to execute one after finishing task of first one. How can i do this?
Saad
  • 235
  • 2
  • 12
2
votes
2 answers

How to make one method wait for another (async) method to finish before continuing execution?

I have searched a lot to find out how others have solved this problem, but unfortunately, I didn't find the answer to this specific question. I would really appreciate your help. Here's a summary: I have two methods in my class, method1 and method2.…
2
votes
2 answers

How to Supress implicit return from a closure with Void return type in Swift

lets consider we have a closure like: (used as completionHandler) func doSomething (completionHandler : (done : Bool)->Void )->Void { ... completionHandler(true) } now if we want to do something like that : doSomething({ (done : Bool)->…
M Abdul Sami
  • 1,522
  • 1
  • 12
  • 16
1
2 3 4