-
Use
NS_DESIGNATED_INITIALIZERfor designated initializers in header (>= iOS 8)// foo.h - (id)initWithFoo:(NSString *)foo NS_DESIGNATED_INITIALIZER;
-
Use
copyonNSStringand `NSArray1 properties; (obviously) does not modify string at original pointer.@property (copy, nonatomic) NSString *foo; @property (copy, nonatomic) NSArray *bar;
-
Register table view reuse identifiers inside data sources.
// TableViewCell.h extern NSString * const TableViewCellReuseIdentifier; // TabieViewCell.m NSString * const TableViewCellReuseIdentifier = @"TableViewCellReuseIdentifier"; // TableViewDataSource.h - (void)registerReuseableCellsWithTableView:(UITableView *)tableView; // TableViewDataSource.m - (void)registerReuseableCellsWithTableView:(UITableView *)tableView { [tableView registerClass:[TableViewCell class] forCellReuseIdentifier:TableViewCellReuseIdentifier]; } // TableViewController.m [self.dataSource registerReuseableCellsWithTableView:self.tableView];
-
Use
instancetypeasinittype where possible (source). -
To set
UINavigationBarback button image:[[UINavigationBar appearance] setBackIndicatorImage:[UIImage imageNamed:@"back.png"]]; [[UINavigationBar appearance] setBackIndicatorTransitionMaskImage:[[UIImage alloc] init]];
-
Use
weakreferences to delegates in delegators; otherwise, the delegate will never de-allocate.@property (weak, nonatomic) id<FooDelegate> delegate;
Last active
August 29, 2015 14:19
-
-
Save nporteschaikin/6add09579987f4b6714b to your computer and use it in GitHub Desktop.
Objective-C notes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment