Xcode comments that show up in the source navigator

Xcode 8.2

Xcode’s source editor is a quick way to navigate the properties and methods of a source file. At the top of each source file, is a dropdown that allows you to jump quickly to where you want to go in any source file. Selecting collectionView in this example will show a menu of items you can jump to.

This is the basic menu.

Using MARK to group the menu

With MARK as a comment, you can add comments to the dropdown.

The result is a menu item in the place that you wrote the MARK comment. You can jump to these like any other method or property.

You can go one better and break sections up into groups just be adding a dash like so.

The result is a divider separating the MARK sections in the menu. It’s a great way to group code together.

TODO and FIXME

Other comments that show up in this menu are FIXME and TODO. You can leave yourself reminders for bugs you find and tasks that you need to do later. A number of languages recognise these comments.

Let’s see them in action in the source menu.

Conclusion

Organising your source menu can logically group together your code, help you to quickly find tasks, and bug comments, and give you quick access to where in the file you need to go. It is especially handy when the source file gets too large.

Leave a Reply

Your email address will not be published. Required fields are marked *