Skip to content

carguezu/objective-c-style-guide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Objective-C style guide

======================= Personal Objective-C style guide.

This style guide is under construction. Feel free to open a pull request.

Sources

NYTimes Objective-C Style Guide

Agbo Objective-C Style Guide

Ray Wenderlich Objective-C style guide

Robots & Pencils Objective-C Style Guide

GitHub Objective-C Style Guide

Apple Coding Guidelines for Cocoa

Language

English should be used.

Code Organization

Use #pragma mark - to categorize methods in functional groupings and protocol/delegate implementations following this general structure.

	#pragma mark - Lifecycle
	
	- (instancetype)init {}
	- (void)dealloc {}
	- (void)viewDidLoad {}
	- (void)viewWillAppear:(BOOL)animated {}
	- (void)didReceiveMemoryWarning {}
		
	#pragma mark - Drawing
	- (void)drawRect:(CGRect) {}
	
	#pragma mark - Overriden Methods
	- (void)someOverriddenMethod {}
		
	#pragma mark - Custom Accessors
	
	- (void)setCustomProperty:(id)value {}
	- (id)customProperty {}
	
	#pragma mark - IBActions
	
	- (IBAction)submitData:(id)sender {}
	
	#pragma mark - Public
	
	- (void)publicMethod {}
	
	#pragma mark - Private
	
	- (void)privateMethod {}
	
	#pragma mark - Protocol conformance
	#pragma mark - UITextFieldDelegate
	#pragma mark - UITableViewDataSource
	#pragma mark - UITableViewDelegate
	#pragma mark - NSCopying
	
	- (id)copyWithZone:(NSZone *)zone {}
	
	#pragma mark - NSObject
	
	- (NSString *)description 

Dot-Notation Syntax

Dot-notation should always be used for accessing and mutating properties. Bracket notation is preferred in all other instances.

For example:

view.backgroundColor = [UIColor orangeColor];
[UIApplication sharedApplication].delegate;

Not:

[view setBackgroundColor:[UIColor orangeColor]];
UIApplication.sharedApplication.delegate;

...

About

Personal Objective-C style guide

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors