NEW: Subscribe to Hacking with Swift+ and accelerate your learning! >>

How to add markers to the jump bar

Swift version: 5.2

Paul Hudson    @twostraws   

Xcode’s jump bar – the popup menu describing all properties and methods in the current class, activated using Ctrl-6 – is a simple way to navigate around your file, particularly when you know you can just type a few letters to automatically filter the list.

However, if you’re finding the jump bar is getting messy, you should try to break it up by adding markers to your code. These come in a few flavors – MARK, TODO, and FIXME – but all help make your jump bar easier to read.

Try adding this special comment before any method:

// TODO: This isn’t finished yet

In the jump bar that will appear as a blue and white list icon so it sticks out. Now try adding this somewhere:

// FIXME: This code is awful.

That will show up in the jump bar with an orange bandaid – it really stands out!

The third option is MARK, which renders your text in bold – it’s great for splitting up the jump bar, and is commonly used to mark divisions in your file.. Try this:

// MARK: UITableViewDataSource methods

All of these markers can have dashes placed before or after the text to make separators. For example:

// FIXME: - This code is really broken -

That will appear in the jump bar with a dividing line before and after the marker. You can just create the separator if you want, like this:

// MARK: -

That just creates a dividing line with no accompanying text.

Hacking with Swift is sponsored by Instabug

SPONSORED Are you tired of wasting time debugging your Swift app? Instabug’s SDK is here to help you minimize debugging time by providing you with complete device details, network logs, and reproduction steps with every bug report. All data is attached automatically, and it only takes a line of code to setup. Start your free trial now and get 3 months off exclusively for the Hacking with Swift Community.

Start your free trial!

Sponsor Hacking with Swift and reach the world's largest Swift community!

Available from iOS 8.0

Similar solutions…

About the Swift Knowledge Base

This is part of the Swift Knowledge Base, a free, searchable collection of solutions for common iOS questions.

BUY OUR BOOKS
Buy Pro Swift Buy Swift Design Patterns Buy Testing Swift Buy Hacking with iOS Buy Swift Coding Challenges Buy Swift on Sundays Volume One Buy Server-Side Swift (Vapor Edition) Buy Advanced iOS Volume One Buy Advanced iOS Volume Two Buy Advanced iOS Volume Three Buy Hacking with watchOS Buy Hacking with tvOS Buy Hacking with macOS Buy Dive Into SpriteKit Buy Swift in Sixty Seconds Buy Objective-C for Swift Developers Buy Server-Side Swift (Kitura Edition) Buy Beyond Code

Was this page useful? Let us know!

Average rating: 3.0/5

Link copied to your pasteboard.