diff --git a/README.md b/README.md index 24556b7b..e26e1d6a 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,6 @@ programming in style. - [HTML](/html/) - [Java](/java/) - [JavaScript & TypeScript](/javascript-typescript/) -- [Objective-C](/objective-c/) - [Python](/python/) - [Ruby](/ruby/) - [Sass](/sass/) diff --git a/objective-c/README.md b/objective-c/README.md deleted file mode 100644 index 410464b7..00000000 --- a/objective-c/README.md +++ /dev/null @@ -1,43 +0,0 @@ -# Objective-C - -[Sample](sample.m) - -- Setup new projects using [Liftoff] and follow provided directory structure. -- Prefer categories on `Foundation` classes to helper methods. -- Prefer string constants to literals when providing keys or key paths to - methods. -- Place `#import`s into the prefix header (`ProjectName-Prefix.pch`) only if - used in _many_ files. -- Place `.xib` files under `Resources/Nibs` and their associated view files in - `Classes/Views`. -- Order `#import` statements alphabetically. -- Order `@class` directives alphabetically. -- Order `@property` modifiers: memory management, atomicity, writability. -- Leave out `@property` modifiers unless needed, `nonatomic` is the only one - needed in most cases. -- Prefer strong IBOutlet references. -- Prefer `@class` to `#import` when referring to external classes in a public - `@interface`. -- Prefer `@property` to declaring instance variables. -- Prefix class names with a 2 or 3 letter project acronym. -- Prefix string constants being used as keys with 'k'. -- Remove `#import` statements for `Foundation` and `UIKit` in new project - templates. -- Separate methods by function using `#pragma mark -
` -- Separate sections into subsections using `#pragma mark ` -- Use `@[arrayObject]`, `@{@"key" : value}`, `@(YES or NO)`, and `@5.0` - literals. -- Use `@interface ClassName ()` to declare private properties. -- Use `lowerCamelCase` for method names. -- Use `NSAssert` in methods that require the presence of certain arguments. -- Write methods using the happy path. Indent the exceptional cases. Keep the - optimal case in the left-most column. -- Prefer `enumerateObjectsUsingBlock:` when looping through arrays. -- Always use braces with control and loop blocks unless it can easily fit on one - line. -- Place opening brace for control and loop blocks on same line. -- Prefer `NSInteger`, `CGFloat`, and similar macros over `int`, `float`, and - other base types. -- Prefer _Auto Layout_ for view layouts and constraints. - -[liftoff]: https://github.com/thoughtbot/liftoff diff --git a/objective-c/sample.m b/objective-c/sample.m deleted file mode 100644 index a5b7248a..00000000 --- a/objective-c/sample.m +++ /dev/null @@ -1,69 +0,0 @@ -#import "Alpha.h" -#import "Beta.h" - -// Use @interface extensions for private properties -@interface TBClassName () - -// Keep @properties grouped together by function -// Prefer strong IBOutlet references -@property (nonatomic) IBOutlet UISearchBar *searchBar; -@property (nonatomic) IBOutlet UITableView *tableView; - -@property (nonatomic) NSManagedObjectContext *managedObjectContext; -@property (nonatomic) NSFetchedResultsController *fetchedResultsController; - -@property (nonatomic, readonly) TBObject *someObject; - -@end - -// Use static NSString points to consts for string constants -static NSString *const TBConstantName = @"Constant"; -static NSUInteger const TBNumberOfCardsInDeck = 52; - -@implementation ClassName - -/* - - Use #pragma mark to organize code by function - - Use descriptive names for #pragma mark - - Use class names if overriding or implementing protocol methods -*/ -#pragma mark - Initialization - -- (instancetype)initWithCoder:(NSCoder *)aDecoder -{ - self = [super initWithCoder:aDecoder]; - - // Return early if conditions prohibit the intended function of the method - // Use conditionals for exceptional cases - // Keep the 'optimal' path non-indented - if (!self) return nil; - - return self; -} - -#pragma mark - UI - -// Opening brackets belong on the next line -- (void)shuffleCards -{ - // Objective-C literals are your friend - NSDictionary *themeColors = @{RedColor: [UIColor redColor], BlueColor: [UIColor blueColor]}; - NSArray *robots = @[@"Ralph", @"Bender", @"The Iron Giant"]; - - NSMutableArray *deckOfCards = [NSMutableArray array]; - - Card *jokerCard = [Card joker]; - [deckOfCards addObject:jokerCard]; - - // Newlines before and after conditional blocks - for (Card *card in deckOfCards) { - NSLog(@"%@", [card description]); - } - - // Use ! to check for nots. Comparing to 'nil' is redundant - if (![creditCard isValid]) { - //... - } -} - -@end