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?
Subscribe to Blog updates
Thanks, we've got you!
Writing Code Documentation in AppCode
Code documentation can save you a lot of time and headaches. On the other hand, it also takes a lot of effort to write and maintain it. In this article, we will look at the AppCode features that can help you create detailed and well-structured code documentation and keep it updated after code refact…
Polish Your Code with AppCode’s Inspections and Intentions
AppCode is constantly analyzing your code to find parts that can be improved. It provides sets of code inspections and intention actions for each supported language for this exact purpose. Inspections locate unused or redundant code, syntax errors, probable bugs, spelling mistakes, obsolete or redun…
Navigation in AppCode
Navigating through files and source code, especially in complex projects, can eat up a lot of time, which is why it is essential to learn how to move around quickly in your IDE. AppCode provides plenty of navigation features that can help you move faster. In this blog post, we’ll take a look at some…
Server-side Swift in AppCode
In this short article we’ll take a look at various AppCode features that are useful for server-side Swift development, as now you can open standalone SPM projects in AppCode on macOS. Check out and open the project On the Welcome screen, click the Get from VCS button and enter the address of the Fe…