Philipp Jahoda Philipp Jahoda - 3 months ago 6
iOS Question

How to write this objective-c block in swift syntax?

I have the following objective-c block.
I cannot figure out how to write it in swift syntax.
This is how the block is defined in objective-c:

formatter = ^(CGFloat value){

// do something with value

return "stringrepresentation";

Could someone be kind and show me the correct syntax?

ADDITIONAL Info: the "formatter" value needs to be of type

How to achieve this?


Look at closures.

{(/*Parameters*/) -> /*ReturnType*/ in
    // Statements

So this block would be:

{(value : CGFloat) -> String in
    // Do cool stuff
    retun "aString"