See original in Ray Wenderlich code style guide
Put bracket on next line for functions.
Preferred:
- (void)someMethod
{
if ([smth boolValue]) {
// then something
}
}
Not Preferred:
- (void)someMethod {
if ([smth boolValue]) {
//Do something important
}
}
Use NSInteger, instead of int; NSUInteger vs unsigned int; etc
Preferred:
- (void)someMethodWithInteger:(NSInteger)myInt
{
}
Not Preferred:
- (void)someMethodWithInteger:(int)myInt
{
}
Don't use more than one empty line, no spaces in method name. It pollutes code and makes it hard to read.
Preferred:
- (void)someMethodWithInt:(NSInteger)myValue
{
if(someCondition) {
[someObject someMethod];
}
}
Not Preferred:
///////////////
/////// my super duper function /////
//////////////
- (void) someMethodWithInt : (NSInteger) myValue
{
if (someCondition){
[ someObject someMethod ];
}
}
If your code intended to be shared with other - is a public API => write docs when possible.
Preferred:
/**
A class method for creating new entities.
@returns Returns en entity with given integer number.
@code
id entry = [MyClass createNewEntryWithInteger:147];
@endcode
Example above returns object of class MyClass.
*/
+ (void)createNewEntryWithInteger:(NSInteger)entryInteger
{
}
Not Preferred:
+ (void)createNewEntryWithInteger:(NSInteger)entryInteger
{
}
There are several ways to use pragma mark correctly, please use them.
Preferred:
#pragma mark - this puts hline before and after -
#pragma mark - this puts hline before
#pragma mark this puts hline after -
#pragma mark just bold text
Not Preferred:
#pragma mark -=dont do this please=-