Last active
December 31, 2015 11:59
-
-
Save luckydev/7982898 to your computer and use it in GitHub Desktop.
Basic Style guidelines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
How to declare a method: | |
- (returntype)nameofTheMethodParam:(paramtype)paramname andAnotherParam:(paramtype)paramname; | |
+ (returntype)nameofTheMethodParam:(paramtype)paramname andAnotherParam:(paramtype)paramname; | |
Not like these: | |
-(returntype)nameofTheMethodParam:(paramtype)paramname andAnotherParam:(paramtype)paramname; | |
-(returntype) nameofTheMethodParam:(paramtype)paramname andAnotherParam:(paramtype)paramname; | |
Note the space between - and start of the declaration. | |
How to define a method: | |
- (returntype)nameofTheMethodParam:(paramtype)paramname andAnotherParam:(paramtype)paramname | |
{ | |
} | |
and not | |
- (returntype)nameofTheMethodParam:(paramtype)paramname andAnotherParam:(paramtype)paramname { | |
} | |
How to write return statements. | |
- (returntype)nameofTheMethodParam:(paramtype)paramname andAnotherParam:(paramtype)paramname | |
{ | |
return something; | |
} | |
Note there are has to be one line space above and below any return statement you write. | |
How to declare properties: | |
@property (nonatomic, strong) NSString* instanceBaseURL; | |
Not like | |
@property ( nonatomic,strong) NSString* instanceBaseURL; | |
@property(nonatomic,strong) NSString* instanceBaseURL; | |
Note one character space on either side of brackets. | |
Also note one character space after a comma, before starting “strong”. | |
if, for and while constructs: | |
Always leave at least one line space before and after “if” constructs. do this also for “for”, “while” or any other characteristics. | |
i=1; | |
//onelienspace | |
if(i==1) | |
{ | |
} | |
//onelienspace | |
print(“do something”); | |
In a .h file, group together propertries, instance methods and class methods. LIke. | |
@interface SomeNewClass:NSObject | |
@property (nonatomic, strong) NSMutableArray* kbArray; // Stores Kb articles | |
@property (nonatomic, strong) NSMutableArray* filterArray; // Stores search result | |
@property (nonatomic, strong) NSArray* someOtherArray; | |
- (returntype)nameofTheMethodParam:(paramtype)paramname andAnotherParam:(paramtype)paramname; | |
- (returntype)nameofTheMethodParam:(paramtype)paramname andAnotherParam:(paramtype)paramname; | |
+ (returntype)nameofTheMethodParam:(paramtype)paramname andAnotherParam:(paramtype)paramname; | |
+ (returntype)nameofTheMethodParam:(paramtype)paramname andAnotherParam:(paramtype)paramname; | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment