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

fix: crash on xcode8; add Installing All Snippets to README #61

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 18 additions & 1 deletion README.md
Expand Up @@ -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.
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.

2 changes: 1 addition & 1 deletion 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#>];
Expand Down
2 changes: 1 addition & 1 deletion checkerror.m
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion 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#> ()
Expand Down
2 changes: 1 addition & 1 deletion cvds.m
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion 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]];
2 changes: 1 addition & 1 deletion 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 = ({
Expand Down
2 changes: 1 addition & 1 deletion frc.m
Expand Up @@ -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 *)#>];
Expand Down
2 changes: 1 addition & 1 deletion frcd.m
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion imv.m
Expand Up @@ -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#>"]]
2 changes: 1 addition & 1 deletion 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];
Expand Down
2 changes: 1 addition & 1 deletion library.m
@@ -1,6 +1,6 @@
---
title: "Library Directory Path"
completion-scope: Function or Method
completion-scope: CodeBlock
---

[NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) firstObject];
2 changes: 1 addition & 1 deletion lifecycle.m
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mailcomp.m
Expand Up @@ -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 <MessageUI/MessageUI.h>
Expand Down
6 changes: 3 additions & 3 deletions mark.m
Expand Up @@ -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#>
2 changes: 1 addition & 1 deletion 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
Expand Down
2 changes: 1 addition & 1 deletion nsl.m
@@ -1,6 +1,6 @@
---
title: "NSLocalizedString"
completion-scope: Code Expression
completion-scope: CodeExpression
---

NSLocalizedString(@"<#Message#>", <#Comment#>)
2 changes: 1 addition & 1 deletion pdel.m
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pds.m
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion 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#> {
Expand Down
2 changes: 1 addition & 1 deletion stack.m
@@ -1,6 +1,6 @@
---
title: "Log Stack Trace"
completion-scope: Function or Method
completion-scope: CodeBlock
---

NSLog(@"Call Stack: %@", [NSThread callStackSymbols]);
2 changes: 1 addition & 1 deletion 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#>;
2 changes: 1 addition & 1 deletion tu.m
@@ -1,7 +1,7 @@
---
title: "UIControlEventTouchUpInside"
platform: iOS
completion-scope: Code Expression
completion-scope: CodeExpression
---

UIControlEventTouchUpInside
2 changes: 1 addition & 1 deletion tvdel.m
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tvds.m
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion 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;
2 changes: 1 addition & 1 deletion 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#>);
2 changes: 1 addition & 1 deletion 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#>);
2 changes: 1 addition & 1 deletion 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#>);
2 changes: 1 addition & 1 deletion 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#>);
2 changes: 1 addition & 1 deletion 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#>);