In Objective-C, we often insert
#param in our code to separate different parts of the code and keep them organized. By doing so, we can see a list of codes with param mark title above the methods name in the navigation bar of Xcode. By clicking the items in the list, we can jump in the code quickly.
It is a really useful feature in Xcode, which is available in Swift as well. Now, we can add a special comment
// MARK:, followed by the detail information, instead of the
#param in our Swift code. The same label as before with a bold font will show up in the navigation list like this:
If we add a dash symbol (
// MARK:, a horizontal divide line will show up in the navigation list.
// MARK:, Xcode supports two types of mark comment, which are
// TODO: and
// FIXME:. Different from
MARK, the "TODO" and "FIXME" text will also be displayed as well as the detail text following the tag itself. When reading source code, the first thing would be open the navigation list and see if there is any todo or bad code to fix.
There is another prevalent mark symbol in Objective-C, which is
#warning will trigger a yellow warning when compiling. It is really a convenient way to remind the user of your code something important. Unfortunately, there is no equivalent mark in Swift. That says, we CANNOT use something like this to trigger a warning. It will just be a normal comment.
// WARNING: Add your API key here
Hope we can see this feature back in a later Swift and Xcode version.