Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Commenting standards while writing iOS applications?

G'Day Programmers, I am from Java background however I have just started learning C++ and Objective C. I was worried when I so lots of different coding style in third party Objective C code. But I am kind a stuck with a dilemma.

My dilemma is whether to use #pragma tags while coding iOS application? Does it considered to be a good practise? Or it is programmer's own choice to have those directive drop down links?

Your expertise and industry experience will be helpful,

Thanks


  • Content I searched on internet were mostly suggesting what #pragma does. But I couldn't find much information regarding whether it is considered to be good practise or not.
like image 948
TeaCupApp Avatar asked Nov 09 '11 12:11

TeaCupApp


People also ask

How do I comment out code in Xcode?

By selecting a few lines of code (pressing ⇧+↑ or ⇧+↓), you can comment a bunch of lines in a single shot with the ⌘ + / shortcut. If the lines are already comments, the same shortcut will uncomment them.

How do you comment a function in Swift?

Type /// or /** */ to begin a documentation comment and then use DocC's special dialect of Markdown to write the content. This dialect supports many keywords like - Parameters: for describing function arguments or - Returns: for describing return values.

What are coding standards for iOS app development?

App DevelopmentiOS iOS Best Practices and SWIFT Coding Standards: A Developer’s Guide byManu S SitharaFebruary 28, 2020 Coding standards act as a guideline for ensuring quality and continuity in code. A set of good practices can help developers over come safety and performance concerns of their end product.

Should you comment your code?

Yes. Does it mean you should never comment your code? No. In this article we’ll look at the good, the bad, and the ugly when it comes to commenting your code. For starters, there are really two different types of code comments. I call them documentation comments and clarification comments.

What are the iOS best practices and Swift coding standards?

iOS best practices and Swift coding standards listed below will ensure that your code is efficient, error-free, simple and enables easy maintenance and bug rectification. 1. Correctness Strive to make your code compile without warnings. This rule informs many style decisions such as using #selectortypes instead of string literals. 2. Naming

What is a clarification comment in code?

Often, a clarification comment is a code smell. It tells you that your code is too complex. You should strive to remove clarification comments and simplify the code instead because, “good code is self-documenting.” Here’s an example of a bad — though very entertaining — clarification comment.


2 Answers

I usually use #pragma to separate implementations, like:

#pragma mark UITableViewDelegate Methods

#pragma mark Custom functionality Methods

So i can look at the drop down menu and go directly to where i want.

like image 90
alexandresoli Avatar answered Oct 03 '22 03:10

alexandresoli


I also use

 #pragma mark - UISomeDelegate

or

 #pragma mark -

XCode separates methods list with a line in navigation bar:

Line above UISomeDelegate

like image 21
Vadim Avatar answered Oct 03 '22 01:10

Vadim