Skip to content
This repository was archived by the owner on Jun 27, 2020. It is now read-only.

Commit 0ccd8cb

Browse files
committed
Converting snippets into new format with YAML front-matter
1 parent 3a6258f commit 0ccd8cb

31 files changed

+172
-187
lines changed

async.m

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
// dispatch_async Pattern for Background Processing
2-
// Dispatch to do work in the background, and then to the main queue with the results
3-
//
4-
// Platform: All
5-
// Language: Objective-C
6-
// Completion Scope: Function or Method
1+
---
2+
title: "dispatch_async Pattern for Background Processing"
3+
summary: "Dispatch to do work in the background, and then to the main queue with the results"
4+
completion-scope: Function or Method
5+
---
76

87
dispatch_async(dispatch_get_global_queue(<#dispatch_queue_priority_t priority#>, <#unsigned long flags#>), ^(void) {
98
<#code#>
10-
9+
1110
dispatch_async(dispatch_get_main_queue(), ^(void) {
1211
<#code#>
1312
});

cdfetch.m

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
// Core Data Fetch
2-
// Simple Core Data Fetch with Predicate & Sort Descriptor
3-
//
4-
// Platform: iOS
5-
// Language: Objective-C
6-
// Completion Scope: Function or Method
1+
---
2+
title: "Core Data Fetch"
3+
summary: "Simple Core Data Fetch with Predicate & Sort Descriptor"
4+
completion-scope: Function or Method
5+
---
76

87
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:<#entityName#>];
98
fetchRequest.predicate = [NSPredicate predicateWithFormat:<#predicateFormat#>];

checkerror.m

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
// CheckError
2-
// Function that extracts human-readable information from OSStatus codes.
3-
// Credit: "Learning Core Audio: A Hands-on Guide to Audio Programming for Mac and iOS", by Chris Adamson, Kevin Avila
4-
//
5-
// Platform: All
6-
// Language: C
7-
// Completion Scope: Code Expression, Function or Method
1+
---
2+
title: "CheckError"
3+
summary: "Function that extracts human-readable information from OSStatus codes."
4+
credit: "'Learning Core Audio: A Hands-on Guide to Audio Programming for Mac and iOS', by Chris Adamson, Kevin Avila"
5+
completion-scopes:
6+
- Code Expression
7+
- Function or Method
8+
---
89

910
static void CheckError(OSStatus error, const char *operation) {
1011
if (error == noErr) {
1112
return;
1213
}
13-
14+
1415
char str[20];
1516
*(UInt32 *) (str + 1) = CFSwapInt32HostToBig(error);
1617
if (isprint(str[1]) && isprint(str[2]) && isprint(str[3]) && isprint(str[4])) {
@@ -19,7 +20,7 @@ static void CheckError(OSStatus error, const char *operation) {
1920
} else {
2021
sprintf(str, "%d", (int)error);
2122
}
22-
23+
2324
fprintf(stderr, "[Error] %s (%s)\n", operation, str);
2425
exit(1);
2526
}

continuation.m

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
// Class Continuation
2-
// Anonymous category to define private methods in an implementation
3-
//
4-
// Platform: All
5-
// Language: Objective-C
6-
// Completion Scope: Top Level
1+
---
2+
title: "Class Continuation"
3+
summary: "Anonymous category to define private methods in an implementation"
4+
completion-scope: Top Level
5+
---
76

87
@interface <#Class Name#> ()
98
<#Continuation#>

cvds.m

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// UICollectionViewDataSource
2-
// Placeholders for essential UICollectionViewDataSource delegate methods
3-
//
4-
// Platform: iOS
5-
// Language: Objective-C
6-
// Completion Scope: Class Implementation
1+
---
2+
title: "UICollectionViewDataSource"
3+
summary: "Placeholders for essential UICollectionViewDataSource delegate methods"
4+
platform: iOS
5+
completion-scope: Class Implementation
6+
---
77

88
#pragma mark - UICollectionViewDataSource
99

documents.m

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
// Documents Directory Path
2-
//
3-
// Platform: All
4-
// Language: Objective-C
5-
// Completion Scope: Function or Method
1+
---
2+
title: "Documents Directory Path"
3+
completion-scope: Function or Method
4+
---
65

76
NSURL *documentsDirectoryURL = [NSURL fileURLWithPath:[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]];

frame.m

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// Set Frame
2-
// Initializes a view frame inside a code block
3-
// Platform: All
4-
// Language: Objective-C
5-
// Completion Scope: Function or Method
1+
---
2+
title: "Set Frame"
3+
summary: "Initializes a view frame inside a code block"
4+
completion-scope: Function or Method
5+
---
66

77
<# view #>.frame = ({
88
CGRect frame = <# view #>.frame;

frc.m

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// NSFetchedResultsController
2-
// Boilerplate for creating an NSFetchedResultsController
3-
//
4-
// Platform: iOS
5-
// Language: Objective-C
6-
// Completion Scope: Function or Method
1+
---
2+
title: "NSFetchedResultsController"
3+
summary: "Boilerplate for creating an NSFetchedResultsController"
4+
platform: iOS
5+
completion-scope: Function or Method
6+
---
77

88
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:<#(NSString *)#>];
99
fetchRequest.predicate = [NSPredicate predicateWithFormat:<#(NSString *), ...#>];

frcd.m

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// NSFetchedResultsControllerDelegate
2-
// Placeholders for the fetched results controller delegate methods
3-
//
4-
// Platform: iOS
5-
// Language: Objective-C
6-
// Completion Scope: Class Implementation
1+
---
2+
title: "NSFetchedResultsControllerDelegate"
3+
summary: "Placeholders for the fetched results controller delegate methods"
4+
platform: iOS
5+
completion-scope: Class Implementation
6+
---
77

88
#pragma mark - NSFetchedResultsControllerDelegate
99

imv.m

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// ImageView
2-
// Create & Initialize UIImageView with Named Image
3-
//
4-
// Platform: iOS
5-
// Language: Objective-C
6-
// Completion Scope: Code Expression
1+
---
2+
title: "ImageView"
3+
summary: "Create & Initialize UIImageView with Named Image"
4+
platform: iOS
5+
completion-scope: Code Expression
6+
---
77

88
[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"<#image name#>"]]

init.m

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
// init
2-
// Designated incantation for your designated initializers
3-
//
4-
// Platform: All
5-
// Language: Objective-C
6-
// Completion Scope: Function or Method
1+
---
2+
title: "init"
3+
summary: "Designated incantation for your designated initializers"
4+
completion-scope: Function or Method
5+
---
76

87
self = [super init];
98
if (!self) {

library.m

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
// Library Directory Path
2-
//
3-
// Platform: All
4-
// Language: Objective-C
5-
// Completion Scope: Function or Method
1+
---
2+
title: "Library Directory Path"
3+
completion-scope: Function or Method
4+
---
65

76
[NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) firstObject];

lifecycle.m

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// UIViewController Lifecycle
2-
// Placeholders for all of the view controller lifecycle methods
3-
//
4-
// Platform: iOS
5-
// Language: Objective-C
6-
// Completion Scope: Class Implementation
1+
---
2+
title: "UIViewController Lifecycle"
3+
summary: "Placeholders for all of the view controller lifecycle methods"
4+
platform: iOS
5+
completion-scope: Class Implementation
6+
---
77

88
#pragma mark - UIViewController
99

mailcomp.m

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// MFMailComposeViewController Initialization & Delegate
2-
// Methods required to use the iOS Mail Composer
3-
//
4-
// Platform: iOS
5-
// Language: Objective-C
6-
// Completion Scope: Class Implementation
1+
---
2+
title: "MFMailComposeViewController Initialization & Delegate"
3+
summary: "Methods required to use the iOS Mail Composer"
4+
platform: iOS
5+
completion-scope: Class Implementation
6+
---
77

88
#import <MessageUI/MessageUI.h>
99

mark.m

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
// #pragma Mark
2-
// Dividers and labels to organize your code into sections
3-
//
4-
// Platform: All
5-
// Language: Objective-C
6-
// Completion Scopes: Top Level, Class Implementation, Class Interface Methods
1+
---
2+
title: "#pragma Mark"
3+
summary: "Dividers and labels to organize your code into sections"
4+
completion-scopes:
5+
- Top Level
6+
- Class Implementation
7+
- Class Interface Methods
8+
---
79

810
#pragma mark - <#Section#>

nscoding.m

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
// NSCoding Protocol Methods
2-
// Placeholders for NSCoding protocol methods
3-
//
4-
// Platform: All
5-
// Language: Objective-C
6-
// Completion Scope: Class Implementation
1+
---
2+
title: "NSCoding Protocol Methods"
3+
summary: "Placeholders for NSCoding protocol methods"
4+
completion-scope: Class Implementation
5+
---
76

87
#pragma mark - NSCoding
98

nsl.m

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
// NSLocalizedString
2-
//
3-
// Platform: All
4-
// Language: Objective-C
5-
// Completion Scope: Code Expression
1+
---
2+
title: "NSLocalizedString"
3+
completion-scope: Code Expression
4+
---
65

76
NSLocalizedString(@"<#Message#>", <#Comment#>)

pdel.m

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
// UIPickerViewDelegate
2-
// Placeholders for required UIPickerView Delegate methods
3-
//
4-
// Platform: iOS
5-
// Language: Objective-C
6-
// Completion Scope: Class Implementation
1+
title: "UIPickerViewDelegate"
2+
summary: "Placeholders for required UIPickerView Delegate methods"
3+
platform: iOS
4+
completion-scope: Class Implementation
5+
---
76

87
#pragma mark - UIPickerViewDelegate
98

pds.m

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// UIPickerViewDataSource
2-
// Placeholders for required UIPickerView datasource methods
3-
//
4-
// Platform: iOS
5-
// Language: Objective-C
6-
// Completion Scope: Class Implementation
1+
---
2+
title: "UIPickerViewDataSource"
3+
summary: "Placeholders for required UIPickerView datasource methods"
4+
platform: iOS
5+
completion-scope: Class Implementation
6+
---
77

88
#pragma mark - UIPickerDataSource
99

singleton.m

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
// Shared Singleton
2-
// Class method that returns a singleton instance
3-
//
4-
// Platform: All
5-
// Language: Objective-C
6-
// Completion Scope: Class Implementation
1+
---
2+
title: "Shared Singleton"
3+
summary: "Class method that returns a singleton instance"
4+
completion-scope: Class Implementation
5+
---
76

87
+ (instancetype)shared<#name#> {
98
static <#class#> *_shared<#name#> = nil;
109
static dispatch_once_t onceToken;
1110
dispatch_once(&onceToken, ^{
1211
_shared<#name#> = <#initializer#>;
1312
});
14-
13+
1514
return _shared<#name#>;
1615
}

stack.m

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
// Log Stack Trace
2-
//
3-
// Platform: All
4-
// Language: Objective-C
5-
// Completion Scope: Function or Method
1+
---
2+
title: "Log Stack Trace"
3+
completion-scope: Function or Method
4+
---
65

76
NSLog(@"Call Stack: %@", [NSThread callStackSymbols]);

strongself.m

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
// __strong self
2-
// Declare strong reference to weak reference
3-
//
4-
// Platform: All
5-
// Language: Objective-C
6-
// Completion Scope: Function or Method
1+
---
2+
title: "__strong self"
3+
summary: "Declare strong reference to weak reference"
4+
completion-scope: Function or Method
5+
---
76

87
__strong __typeof(<#weakSelf#>)strongSelf = <#weakSelf#>;

tu.m

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// UIControlEventTouchUpInside
2-
//
3-
// Platform: iOS
4-
// Language: Objective-C
5-
// Completion Scope: Code Expression
1+
---
2+
title: "UIControlEventTouchUpInside"
3+
platform: iOS
4+
completion-scope: Code Expression
5+
---
66

77
UIControlEventTouchUpInside

tvdel.m

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
// UITableViewDelegate
2-
// Placeholders for required UITableViewDelegate protocol methods
3-
//
4-
// Platform: iOS
5-
// Language: Objective-C
6-
// Completion Scope: Class Implementation
1+
---
2+
title: "UITableViewDelegate"
3+
summary: "Placeholders for required UITableViewDelegate protocol methods"
4+
platform: iOS
5+
completion-scope: Class Implementation
6+
---
77

88
#pragma mark - UITableViewDelegate
99

10-
- (void)tableView:(UITableView *)tableView
11-
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
10+
- (void)tableView:(UITableView *)tableView
11+
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
1212
{
1313
<#statements#>
1414
}

0 commit comments

Comments
 (0)