BDGapps
BDGapps

Reputation: 3356

Objective-C to Swift : Pass Completion Handler

I am trying to convert the following to swift but am not sure how to handle the parameters.

- (void)requestDiscoverabilityPermission:(void (^)(BOOL discoverable)) completionHandler{}

Upvotes: 1

Views: 1157

Answers (2)

holex
holex

Reputation: 24041

it would look like e.g. this:

    func requestDiscoverabilityPermission(completionHandler: (discoverable: Bool!) -> ()?) {
        // ...
    }

NOTE: you can play with the optional, non-optional parameters freely in your final code.

Upvotes: 1

Eugene
Eugene

Reputation: 10045

func requestDiscoverabilityPermissionWithCompletion(completion:(discoverable: Boolean) -> Void){}

reference

Upvotes: 1

Related Questions