This repository has been archived by the owner on Jun 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 640
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Importing first batch of snippets from Xcode
- Loading branch information
Showing
8 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// dispatch_async Pattern for Background Processing | ||
// Dispatch to do work in the background, and then to the main queue with the results | ||
// | ||
// Platform: All | ||
// Language: Objective-C | ||
// Completion Scope: Function or Method | ||
|
||
dispatch_async(dispatch_get_global_queue(<#dispatch_queue_priority_t priority#>, <#unsigned long flags#>), ^(void) { | ||
<#code#> | ||
|
||
dispatch_async(dispatch_get_main_queue(), ^(void) { | ||
<#code#> | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Class Continuation | ||
// Anonymous category to define private methods in an implementation | ||
// | ||
// Platform: All | ||
// Language: Objective-C | ||
// Completion Scope: Top Level | ||
|
||
@interface <#Class Name#> () | ||
<#Continuation#> | ||
@end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// init | ||
// Designated incantation for your designated initializers | ||
// | ||
// Platform: All | ||
// Language: Objective-C | ||
// Completion Scope: Function or Method | ||
|
||
self = [super init]; | ||
if (!self) { | ||
return nil; | ||
} | ||
|
||
<#initializations#> | ||
|
||
return self; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// KVO Setter | ||
// Use when overriding @synthesized property setter methods | ||
// | ||
// Platform: All | ||
// Language: Objective-C | ||
// Completion Scope: Function or Method | ||
|
||
[self willChangeValueForKey:@"<#ivar#>"]; | ||
[<#ivar#> autorelease]; | ||
<#ivar#> = [<#newValue#> retain]; | ||
[self didChangeValueForKey:@"<#ivar#>"]; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
mattt
Author
Contributor
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// UIViewController Lifecycle | ||
// Placeholders for all of the view controller lifecycle methods | ||
// | ||
// Platform: iOS | ||
// Language: Objective-C | ||
// Completion Scope: Class Implementation | ||
|
||
#pragma mark - UIViewController | ||
|
||
- (void)viewDidLoad { | ||
[super viewDidLoad]; | ||
} | ||
|
||
- (void)viewDidUnload { | ||
[super viewDidUnload]; | ||
} | ||
|
||
- (void)viewWillAppear:(BOOL)animated { | ||
[super viewWillAppear:animated]; | ||
} | ||
|
||
- (void)viewDidAppear:(BOOL)animated { | ||
[super viewDidAppear:animated]; | ||
} | ||
|
||
- (void)viewWillDisappear:(BOOL)animated { | ||
[super viewWillDisappear:animated]; | ||
} | ||
|
||
- (void)viewDidDisappear:(BOOL)animated { | ||
[super viewDidDisappear:animated]; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// #pragma Mark | ||
// Dividers and labels to organize your code into sections | ||
// | ||
// Platform: All | ||
// Language: Objective-C | ||
// Completion Scopes: Top Level, Class Implementation, Class Interface Methods | ||
|
||
#pragma mark - <#Section#> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// UITableViewDelegate | ||
// Placeholders for the core table view delegate methods | ||
// | ||
// Platform: iOS | ||
// Language: Objective-C | ||
// Completion Scope: Class Implementation | ||
|
||
#pragma mark - UITableViewDelegate | ||
|
||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { | ||
switch (indexPath.section) { | ||
case <#constant#>: | ||
<#statements#> | ||
break; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// UITableViewDataSource | ||
// Placeholders for the core table view data source methods | ||
// | ||
// Platform: All | ||
// Language: iOS | ||
// Completion Scope: Class Implementation | ||
|
||
#pragma mark - UITableViewDataSource | ||
|
||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { | ||
return <# number #>; | ||
} | ||
|
||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { | ||
switch (section) { | ||
case <#constant#>: | ||
<#statements#> | ||
break; | ||
default: | ||
return 0; | ||
} | ||
} | ||
|
||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { | ||
static NSString *CellIdentifier = @"Cell"; | ||
|
||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; | ||
if (!cell) { | ||
cell = [[UITableViewCell alloc] initWithStyle:<#(UITableViewCellStyle)#> reuseIdentifier:CellIdentifier]; | ||
} | ||
|
||
return cell; | ||
} |
You shouldn't call will/did in a setter unless you have disabled automatic will/did using + (BOOL)automaticallyNotifiesObserversForKey:(NSString )key;. The KVO runtime will do that for you just based on the name of the method being "set".