Tips & Tricks

AppCode Code Completion. 101

It’s quite hard to imagine a code editor that doesn’t have code completion nowadays. Seriously, who wants a tool that doesn’t understand what you’re about to do and cannot give you a hand with it?

Given all IntelliJ IDEA and ReSharper history, it would be weird to say the least if AppCode couldn’t be as helpful for Objective-С developers as mentioned tools are for Java and .NET guys. After all, coding assistance was always one of the distinguishing features of JetBrains’ products.

If you’re used to Xcode, you may find it strange at first to discover that there are different code completion types in AppCode: basic (⌃Space), smart type(⌃⇧Space) and some others which are of no interest for us right now. Why would we need to have 2 major completions separated and what’s the difference between them?

Basic code completion (⌃Space) is the one everyone expects to be there in a decent IDE: complete the name of any class, method or a variable instantly as you type.
Quite natural, isn’t it? However AppCode is way more intelligent than just that, though we wouldn’t want anyone to think that we know better:) That’s why all the smart completions are separated from the basic ones – you got them when you need them, but there’s no pressure.

Smart Type completion (⌃⇧Space) analyzes the context you are currently working with and prepares the list of choices for you. It filters the list of methods and variables to match the expected expression type. For example, it can suggest a constructor or factory method of a class expected:

This things you may have already known, but here are a few magic tricks!

Trick #1: CamelHumps
To complete your code even faster, and to limit the search suggestions to exactly what you need, just use “CamelHumps”: AppCode identifies parts of compound names composed according to CamelCase, where each part starts with a capital letter.

#1 Class completion with CamelHumps

#2 Method completion with CamelHumps

Trick #2: Autocomplete block arguments
Smart completion (⌃⇧Space) can also make your life easier by completing block arguments:

Trick #3: Smarter completion
Actually there’s more intelligence hidden behind both completion kinds that can be revealed by pressing the corresponding shortcut twice.

  • Press ⌃Space for basic completion twice, and AppCode will find not yet imported symbols (for example, functions) and add the import for you.
  • If Smart Type completion didn’t suggest you anything, try pressing the same shortcut (⌃⇧Space) one more time: AppCode will look up values of the expected type which can be retrieved through a chained method call.

Trick #4: Let AppCode worry about square brackets

When calling a method on a variable you can forget about square brackets – AppCode will add them automatically.


Have you tried AppCode already? What other AppCode features you’d like us to cover?

Stay tuned!

Discover more