diff --git a/README.md b/README.md index 5fbf6c59..073b6b74 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,21 @@ Just a few code snippets I have in my Xcode arsenal. In [dotfiles](http://dotfil In Xcode 4, open a workspace and toggle the right sidebar to be visible. On the bottom, there is a panel with four icons in the header. Click on the `{ }` icon to open the Code Snippets Library. -Now copy-paste the code from one of these snippets, highlight the code block you just pasted and drag it to the Code Snippet panel. Make sure to match the suggested platform, language, and completion scope. The completion shortcut corresponds to the filename of the code snippet. \ No newline at end of file +Now copy-paste the code from one of these snippets, highlight the code block you just pasted and drag it to the Code Snippet panel. Make sure to match the suggested platform, language, and completion scope. The completion shortcut corresponds to the filename of the code snippet. + +## Installing All Snippets + +To get started, install the xcodesnippet gem. + +``` +$ gem install xcodesnippet +``` + +Once installed, navigate to the directory where the snippets repository has been cloned and run + +``` +for f in *.m; do xcodesnippet install $f; done +``` + +This will batch process all of the snippets available in the repository and add them to Xcode. + diff --git a/cdfetch.m b/cdfetch.m index b40b6dba..45fa8d7f 100644 --- a/cdfetch.m +++ b/cdfetch.m @@ -1,7 +1,7 @@ --- title: "Core Data Fetch" summary: "Simple Core Data Fetch with Predicate & Sort Descriptor" -completion-scope: Function or Method +completion-scope: CodeBlock --- NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:<#entityName#>]; diff --git a/checkerror.m b/checkerror.m index 697de927..297755e1 100644 --- a/checkerror.m +++ b/checkerror.m @@ -4,7 +4,7 @@ credit: "'Learning Core Audio: A Hands-on Guide to Audio Programming for Mac and iOS', by Chris Adamson, Kevin Avila" completion-scopes: - Code Expression - - Function or Method + - CodeBlock --- static void CheckError(OSStatus error, const char *operation) { diff --git a/continuation.m b/continuation.m index 1a5747f0..2019e815 100644 --- a/continuation.m +++ b/continuation.m @@ -1,7 +1,7 @@ --- title: "Class Continuation" summary: "Anonymous category to define private methods in an implementation" -completion-scope: Top Level +completion-scope: TopLevel --- @interface <#Class Name#> () diff --git a/cvds.m b/cvds.m index 0f35ee9e..e9be8c37 100644 --- a/cvds.m +++ b/cvds.m @@ -2,7 +2,7 @@ title: "UICollectionViewDataSource" summary: "Placeholders for essential UICollectionViewDataSource delegate methods" platform: iOS -completion-scope: Class Implementation +completion-scope: ClassImplementation --- #pragma mark - UICollectionViewDataSource diff --git a/documents.m b/documents.m index 9443ce0e..032c33f5 100644 --- a/documents.m +++ b/documents.m @@ -1,6 +1,6 @@ --- title: "Documents Directory Path" -completion-scope: Function or Method +completion-scope: CodeBlock --- NSURL *documentsDirectoryURL = [NSURL fileURLWithPath:[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]]; diff --git a/frame.m b/frame.m index dfd8ecd1..b7c7c588 100644 --- a/frame.m +++ b/frame.m @@ -1,7 +1,7 @@ --- title: "Set Frame" summary: "Initializes a view frame inside a code block" -completion-scope: Function or Method +completion-scope: CodeBlock --- <# view #>.frame = ({ diff --git a/frc.m b/frc.m index 6cc24b0a..46b81c01 100644 --- a/frc.m +++ b/frc.m @@ -2,7 +2,7 @@ title: "NSFetchedResultsController" summary: "Boilerplate for creating an NSFetchedResultsController" platform: iOS -completion-scope: Function or Method +completion-scope: CodeBlock --- NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:<#(NSString *)#>]; diff --git a/frcd.m b/frcd.m index 6949e7b8..76e1831c 100644 --- a/frcd.m +++ b/frcd.m @@ -2,7 +2,7 @@ title: "NSFetchedResultsControllerDelegate" summary: "Placeholders for the fetched results controller delegate methods" platform: iOS -completion-scope: Class Implementation +completion-scope: ClassImplementation --- #pragma mark - NSFetchedResultsControllerDelegate diff --git a/imv.m b/imv.m index 6c7a7866..e77634ec 100644 --- a/imv.m +++ b/imv.m @@ -2,7 +2,7 @@ title: "ImageView" summary: "Create & Initialize UIImageView with Named Image" platform: iOS -completion-scope: Code Expression +completion-scope: CodeExpression --- [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"<#image name#>"]] diff --git a/init.m b/init.m index 051af82b..9352fcbc 100644 --- a/init.m +++ b/init.m @@ -1,7 +1,7 @@ --- title: "init" summary: "Designated incantation for your designated initializers" -completion-scope: Function or Method +completion-scope: CodeBlock --- self = [super init]; diff --git a/library.m b/library.m index 25e13b2e..5a9c8538 100644 --- a/library.m +++ b/library.m @@ -1,6 +1,6 @@ --- title: "Library Directory Path" -completion-scope: Function or Method +completion-scope: CodeBlock --- [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) firstObject]; diff --git a/lifecycle.m b/lifecycle.m index 3e28940a..bb70036c 100644 --- a/lifecycle.m +++ b/lifecycle.m @@ -2,7 +2,7 @@ title: "UIViewController Lifecycle" summary: "Placeholders for all of the view controller lifecycle methods" platform: iOS -completion-scope: Class Implementation +completion-scope: ClassImplementation --- #pragma mark - UIViewController diff --git a/mailcomp.m b/mailcomp.m index e1fe92a4..34a9c7e0 100644 --- a/mailcomp.m +++ b/mailcomp.m @@ -2,7 +2,7 @@ title: "MFMailComposeViewController Initialization & Delegate" summary: "Methods required to use the iOS Mail Composer" platform: iOS -completion-scope: Class Implementation +completion-scope: ClassImplementation --- #import diff --git a/mark.m b/mark.m index 3a089b83..ce32d4c4 100644 --- a/mark.m +++ b/mark.m @@ -2,9 +2,9 @@ title: "#pragma Mark" summary: "Dividers and labels to organize your code into sections" completion-scopes: - - Top Level - - Class Implementation - - Class Interface Methods + - TopLevel + - ClassImplementation + - ClassInterfaceMethods --- #pragma mark - <#Section#> diff --git a/nscoding.m b/nscoding.m index e95b6da2..16ef6e4c 100644 --- a/nscoding.m +++ b/nscoding.m @@ -1,7 +1,7 @@ --- title: "NSCoding Protocol Methods" summary: "Placeholders for NSCoding protocol methods" -completion-scope: Class Implementation +completion-scope: ClassImplementation --- #pragma mark - NSCoding diff --git a/nsl.m b/nsl.m index 39a69699..be801fe3 100644 --- a/nsl.m +++ b/nsl.m @@ -1,6 +1,6 @@ --- title: "NSLocalizedString" -completion-scope: Code Expression +completion-scope: CodeExpression --- NSLocalizedString(@"<#Message#>", <#Comment#>) diff --git a/pdel.m b/pdel.m index 2c77b14b..97d4b117 100644 --- a/pdel.m +++ b/pdel.m @@ -2,7 +2,7 @@ title: "UIPickerViewDelegate" summary: "Placeholders for required UIPickerView Delegate methods" platform: iOS -completion-scope: Class Implementation +completion-scope: ClassImplementation --- #pragma mark - UIPickerViewDelegate diff --git a/pds.m b/pds.m index 01d01a7e..bbbfe29b 100644 --- a/pds.m +++ b/pds.m @@ -2,7 +2,7 @@ title: "UIPickerViewDataSource" summary: "Placeholders for required UIPickerView datasource methods" platform: iOS -completion-scope: Class Implementation +completion-scope: ClassImplementation --- #pragma mark - UIPickerDataSource diff --git a/singleton.m b/singleton.m index 49cca018..21f5693d 100644 --- a/singleton.m +++ b/singleton.m @@ -1,7 +1,7 @@ --- title: "Shared Singleton" summary: "Class method that returns a singleton instance" -completion-scope: Class Implementation +completion-scope: ClassImplementation --- + (instancetype)shared<#name#> { diff --git a/stack.m b/stack.m index 84a91a1a..5490b8b8 100644 --- a/stack.m +++ b/stack.m @@ -1,6 +1,6 @@ --- title: "Log Stack Trace" -completion-scope: Function or Method +completion-scope: CodeBlock --- NSLog(@"Call Stack: %@", [NSThread callStackSymbols]); diff --git a/strongself.m b/strongself.m index fa53594d..1250874a 100644 --- a/strongself.m +++ b/strongself.m @@ -1,7 +1,7 @@ --- title: "__strong self" summary: "Declare strong reference to weak reference" -completion-scope: Function or Method +completion-scope: CodeBlock --- __strong __typeof(<#weakSelf#>)strongSelf = <#weakSelf#>; diff --git a/tu.m b/tu.m index 8f77dde6..18109daf 100644 --- a/tu.m +++ b/tu.m @@ -1,7 +1,7 @@ --- title: "UIControlEventTouchUpInside" platform: iOS -completion-scope: Code Expression +completion-scope: CodeExpression --- UIControlEventTouchUpInside diff --git a/tvdel.m b/tvdel.m index 547ea443..f883fe85 100644 --- a/tvdel.m +++ b/tvdel.m @@ -2,7 +2,7 @@ title: "UITableViewDelegate" summary: "Placeholders for required UITableViewDelegate protocol methods" platform: iOS -completion-scope: Class Implementation +completion-scope: ClassImplementation --- #pragma mark - UITableViewDelegate diff --git a/tvds.m b/tvds.m index 7197a232..e217d3b7 100644 --- a/tvds.m +++ b/tvds.m @@ -2,7 +2,7 @@ title: "UITableViewDataSource" summary: "Placeholders for required UITableViewDataSource delegate methods" platform: iOS -completion-scope: Class Implementation +completion-scope: ClassImplementation --- #pragma mark - UITableViewDataSource diff --git a/weakself.m b/weakself.m index 40a15129..a963fe2e 100644 --- a/weakself.m +++ b/weakself.m @@ -1,7 +1,7 @@ --- title: "__weak self" summary: "Declare weak reference to self" -completion-scope: Function or Method +completion-scope: CodeBlock --- __weak typeof(self)weakSelf = self; diff --git a/xae.m b/xae.m index 891b2507..cf45808a 100644 --- a/xae.m +++ b/xae.m @@ -1,7 +1,7 @@ --- title: "XCT Assert Equals" summary: "Assert equals for XCTest" -completion-scope: Function or Method +completion-scope: CodeBlock --- XCTAssertEqual(<#expected#>, <#actual#>, <#message#>); diff --git a/xaf.m b/xaf.m index a360e469..cd95e582 100644 --- a/xaf.m +++ b/xaf.m @@ -1,7 +1,7 @@ --- title: "XCT Assert False" summary: "Assert false for XCTest" -completion-scope: Function or Method +completion-scope: CodeBlock --- XCTAssertFalse(<#expression#>, <#message#>); diff --git a/xan.m b/xan.m index e9941d54..c19e820b 100644 --- a/xan.m +++ b/xan.m @@ -1,7 +1,7 @@ --- title: "XCT Assert Nil" summary: "Assert for XCTest" -completion-scope: Function or Method +completion-scope: CodeBlock --- XCTAssertNil(<#expression#>, <#message#>); diff --git a/xann.m b/xann.m index e434b513..dca6d12e 100644 --- a/xann.m +++ b/xann.m @@ -1,7 +1,7 @@ --- title: "XCT Assert Not Nil" summary: "Assert not nil for XCTest" -completion-scope: Function or Method +completion-scope: CodeBlock --- XCTAssertNotNil(<#expression#>, <#message#>); diff --git a/xat.m b/xat.m index 71e434d7..0c1a190a 100644 --- a/xat.m +++ b/xat.m @@ -1,7 +1,7 @@ --- title: "XCT Assert True" summary: "Assert true for XCTest" -completion-scope: Function or Method +completion-scope: CodeBlock --- XCTAssertTrue(<#expression#>, <#message#>);