6

We all know and love the autocomplete feature of Xcode. enter image description here The above screenshot is taken from Xcode 9. I looks identical to what it did in Xcode 8. It knows about my class, and all of its different declarations and functions etc. This is not a SearchPaths-problem.

In Xcode 8, we were able to start typing the function name or the name of any variable used in the declaration of any function/initialiser to help the autocomplete single out which we want, like this: enter image description here

However, in Xcode 9 this no longer happens. Instead, it completely ignores context and starts to show autocompletion as if I was typing this on a new line. enter image description here Is there a way to enable this again? I didn't know I needed this function until I lost it.

Sti
  • 8,275
  • 9
  • 62
  • 124

1 Answers1

0

This happens to me in XCode 9.3, but only (it seems) if all the following conditions are met:

  1. The instance is created from a different file or scope than the type definition
  2. The instance is not created from within a function
  3. An instance of the same type has not already been created at the current scope. (As discussed here.)

This implies some possible workarounds. You can create the instance within a function and then move the line of code elsewhere. Or you can create a dummy instance first, followed by the real instance on the next line—this works even if you don't include the arguments on the dummy line. For example:

let dummy = MyObject  // no autocomplete available here
let obj = MyObject(anything: Any Object)  // autocomplete working on this line!
Kal
  • 2,098
  • 24
  • 23