Summary: Coding standards ensure quality and continuity in your code. The iOS and Swift coding standards have been listed below.
Use Xcode
Xcode is the IDE of choice for most iOS developers, and the only one officially supported by Apple. There are a few alternatives, of which AppCode is possibly the most famous, but unless you are already an iOS expert, opt for Xcode.
CocoaPods
If you're planning on including external dependencies (e.g. third-party libraries) in your project, CocoaPods offers easy and fast integration.
Coding Conventions
Methods defined in Cocoa frameworks-for example, Foundation, AppKit, and UIKit-behave in certain ways under different circumstances. For example:
- Methods that return objects typically return nil if they cannot create or find the object. They do not directly return a status code.
- Methods that perform an operation return a boolean value to indicate success or failure.
- If a method takes a collection object-that is, an NSArray, NSDictionary, or NSSet object-as an argument, do not specify nil to indicate "default" or "no value"; instead, pass an empty collection object.
- If you explicitly manage program memory, follow memory management guidelines and practices.
The following is a sample of API naming conventions:
- Clarity and brevity are important, but never sacrifice clarity for brevity.
- Avoid ambiguous names.
- Use verbs in method or function names that represent actions.
- Use prefixes for class names and for symbols associated with classes, such as functions and data types.