Questions tagged [completion-block]

54 questions
2
votes
1 answer

Return object for a method inside completion block

I want to make a method with URL parameter that returns the response of calling that URL. How can I return the data obtained inside a completion block for a method? class func MakeGetRequest(urlString: String) -> (data: NSData, error: NSError) { …
1
vote
0 answers

Completion Block Not Called When User Is Deleted - Firebase Swift

I am having an error where when I delete my user information the completion block is not called. I have seen answers where the problem regards the completion block however my problem still persists. I am able to successfully delete the user from my…
Rohan Vasishth
  • 417
  • 6
  • 19
1
vote
1 answer

completion handlers in objective c iOS

I was studying blocks and it seems pretty impressive to use. But then I came to know that we can use blocks in functions as variable and its main use is when we want to do some async work that after getting result of something we have to perform…
Sudhanshu Gupta
  • 2,255
  • 3
  • 36
  • 74
1
vote
2 answers

How can I wait for a completion block to finish in objective-c ios

I have a subclass with two methods: - (void) aPostRequest:(NSString *) urlStr andJSON:(NSMutableDictionary*) jsonDict completion:(void (^)(NSDictionary *, NSError *))completion { NSError *error = nil; NSURLSessionConfiguration…
cdub
  • 24,555
  • 57
  • 174
  • 303
1
vote
1 answer

Adding a completion block to a CloudKit function

My ViewController wants to display some data based on a CloudKit query. My CloudKit code is all in a separate class. That class has a function called loadExpenses() that fetches some Expenses entities from CK. I want to be able to call…
Diego Petrucci
  • 221
  • 1
  • 3
  • 11
1
vote
1 answer

using didDismissCompletionHandler in MZFormSheetController

I'm using MZFormSheetController to present modals in my app. There is a situation where I want to present a second sheet controller right after I dismiss the first one. In order to do that, there is a completion block, but I can't figure out how to…
Arel
  • 3,888
  • 6
  • 37
  • 91
1
vote
1 answer

NSURLSession, Completion Block, Swift

Im working with NSURLSession. I have an array with restaurants and i'm requesting the dishes for every restaurant in the array to the api. The dataTask works,i'm just having a real hard time trying to call a method only when the all dataTasks are…
Gama
  • 352
  • 2
  • 16
1
vote
1 answer

How to convert completion block of Objective-C to Swift?

I try to convert Objective-C block syntax to Swift Xcode 6.3.2 completion block typedef: typealias CompletionWithBoolBlock = (Bool, NSError, NSString) -> Void [Model insertObjectWithTable:@"tblStudent" values:dict completion:^(BOOL success, NSError…
Soniya
  • 600
  • 7
  • 34
1
vote
1 answer

How to write and pass a completion block parameter for a method?

I have a method that basically uses this: -(void)myMethodwithDuration:(NSTimeInterval)time{ [UIView animateWithDuration:time animations:^{ // do thing here } …
user339946
  • 5,961
  • 9
  • 52
  • 97
1
vote
1 answer

Completion block thread

I have this piece of code: [[FBController sharedController] getUserDetailsWithCompletionBlock:^(NSDictionary *details) { // Updating UI elements }]; I don't understand a thing: when the block is fired, the secondary thread is still running.…
Chirila Vasile
  • 359
  • 1
  • 2
  • 11
1
vote
1 answer

How to make a method to wait till another method complete it work in Objective C?

Consider this scenario. -(void) mainMethod { [self subMethod1]; [self subMethod2]; } My assumption: When calling the mainMethod, it will call the subMethod1 first, then the subMethod2. But, there is no rule that says "After completing the…
Confused
  • 3,846
  • 7
  • 45
  • 72
0
votes
0 answers

How can I show the completion data inside of ForEach in SwiftUI?

I am a beginner at Swift and SwiftUI and I have a problem showing the completion data inside of ForEach in SwiftUI. I know I am getting the data, because I can print it on the console, but I can't show it in view. Here is my view model: func…
j-kobu
  • 3
  • 2
0
votes
0 answers

Not Executing Function at The Right Time, But Executed After Completion Block

Need help in figuring out why my function is not executing when I thought it should but it executed after the completion block in the code. I am fairly new to Xcode so please excuse me if things sound confusing here. Below is my code. class…
Athena
  • 31
  • 2
0
votes
3 answers

Cannot convert value of type '()' to expected argument type '() -> Void' with a completionHandler

I'm trying to create a completion block where a function can be executed but I keep getting the error: Cannot convert value of type '()' to expected argument type '() -> Void' Here is the function: var labelViews : [LabelViews] = [] private func…
SwiftyJD
  • 5,257
  • 7
  • 41
  • 92
0
votes
0 answers

Microsoft MSAL ObjC - Trying to acquire token Interactively for multiple scopes

I am trying to acquire token Interactively for multiple scopes, Policy and RMS scopes using Objective C. I am not sure whether I am doing it right or wrong, the way I am trying to get it as below. I have written a method "aquireToken" where I am…