rayx
(Huan Xiong)
1
Suppose I have a struct Foo:
struct Foo {
var x: Int
var y: Int?
}
When I create an instance in the code, Xcode skips the y parameter by default when doing auto-completion. To include all parameters, I need to press "Option-Enter" instead.
I find this behavior can easily lead one to miss parameters when modifying a large amount of code. I wonder if there is some setting in Xcode to change the behavior? I googled but found nothing. It would also help if there is a third-party tool to list the function calls that don't contain complete parameters.
(Note: an obvious approach is to not specify default value for parameters of optional type, but I'd like to use the synthesized init() in the above case).
1 Like
tera
2
You may take advantage of the peculiar feature that Int? and Optional<Int> are treated differently:
struct Foo {
var x: Int
var y: Optional<Int>
}
But then you'd need to always specify "y".
I'm not aware of Xcode setting to flip its "Option-Enter" autocomplete behaviour.
2 Likes
rayx
(Huan Xiong)
3
Thank you. I read about their difference in the forum a few days ago, but would never think of this approach if you didn't mention it.
That's what I thought.