Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift escaping block declaration

Tags:

ios

swift

I have the following code:

typealias queryCompletionBlock = (_ finished:Bool) -> Void

func queryForParams(@escaping completion:queryCompletionBlock)

But I get an error

Attribute can only be applied to types, not declarations

The problem is the function requires block to be escaping. How do I declare the above function with an escaping block?

like image 533
Deepak Sharma Avatar asked Aug 24 '26 23:08

Deepak Sharma


2 Answers

func queryForParams(completion: @escaping queryCompletionBlock)
like image 189
Alexander Avatar answered Aug 27 '26 13:08

Alexander


try func queryForParams(completion: @escaping queryCompletionBlock)

like image 34
Yoel Jimenez del valle Avatar answered Aug 27 '26 11:08

Yoel Jimenez del valle



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!