1

I have this Swift block:

var onLoggedIn: ((sender:AnyObject?, showFTUE:Bool) -> ())?

Trying to use it in Obj-C, and XCode 7 autocompletes as:

 [loginController setOnLoggedIn:^(id _Nullable, BOOL) {
        <#code#>
    }];

But then throws an error and tells me parameter name is omitted. I tried inserted the parameter showFTUE in various positions with no luck.

In my Swift translation file it's translated as:



1
  • to clarify, you've tried ^(id _Nullable, BOOL showFTUE)? Commented Oct 23, 2015 at 19:12

1 Answer 1

1

Since Xcode 7, when your completion block declared in .h (in obj-c) doesn't have names (which is default autocomplete behavior from Xcode 7) it will also autocomplete without parameter names. As you can see your block has only types and _Nullable directive, just add parameter names at the end.

[loginController setOnLoggedIn:^(id _Nullable parameterName1, BOOL parameterName1) {
        <#code#>
}];
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.