Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
[Xcode] My beautiful Xcode Code Snippets. Please contribute!
Python Shell
Tree: 2035faf59c

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.generateDescription.py
Localizable-keyValue.codesnippet
NSLocalizedString.codesnippet
README.md
allocInit.codesnippet
autoresizingMask.codesnippet
dequeueTableCell.codesnippet
fori-loop.codesnippet
importFramework.codesnippet
importHeader.codesnippet
pragma-mark.codesnippet
presentAlertView.codesnippet
pushController.codesnippet
stringWithFormat.codesnippet

README.md

CodeSnippets

These are my Xcode 4 CodeSnippets. Just check them out into the following path:

~/Library/Developer/Xcode/UserData/CodeSnippets

And you're ready to go.

Snippet Descriptions

(generated with .generateDescription.py)

allocInit.codesnippet (Initalize an object)
Shortcut: alloc
creates a new object from a given class

<#ClassName#> *<#variableName#> = [[<#ClassName#> alloc] init];

autoresizingMask.codesnippet (Setup autoresizing of a view)
Shortcut: autoresizing
Set the autoresizing flags of a view

<#view#>.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

dequeueTableCell.codesnippet (Create a reusable TableCell)
Shortcut: tablecell
Initialises / deques a new cell from the tableview using an identifier

// create / dequeue cell
static NSString* identifier = @"<#identifier#>";
    UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[<#UITableViewCell#> alloc] initWithStyle:<#UITableViewCellStyleSubtitle#> reuseIdentifier:identifier];
    }

    return cell;

fori-loop.codesnippet (Incrementing For Loop)
Shortcut: fori
A For loop incrementing a local variable

for (NSInteger i=0; i<<#count#>; i++) {
    <#statements#>
}

importFramework.codesnippet (Import Framework)
Shortcut: imp2
import a framework

#import <<#header#>>

importHeader.codesnippet (Import header)
Shortcut: imp1
Import a header

#import "<#header#>"

Localizable-keyValue.codesnippet (Key-Value Pair for Localization)
Shortcut: key
A localization key and its value

"<#keyName#>" = "<#value#>";

NSLocalizedString.codesnippet (Localize a string)
Shortcut: loca
Localizes a string from a given key

NSLocalizedString(@"<#keyName#>", nil)

pragma-mark.codesnippet (Pragma mark)
Shortcut: pragma
Add a new pragma mark

#pragma mark <#comment#>

presentAlertView.codesnippet (Create & show a UIAlertView)
Shortcut: alertview
Shows a newly created alertview

UIAlertView* alertView = [[UIAlertView alloc] initWithTitle: <#title#>
                                                        message: <#message#>
                                                       delegate: <#self#>
                                              cancelButtonTitle: <#nil#>
                                              otherButtonTitles: <#@"OK"#>, nil];
    [alertView show];

pushController.codesnippet (Push a ViewController)
Shortcut: push
Pushes a newly created ViewController on the current NavigationController

<#UIViewController#>* viewController = [[<#UIViewController#> alloc] init];
    [self.navigationController pushViewController:viewController animated:YES];

stringWithFormat.codesnippet (Formatted String)
Shortcut: format
Shortcut for a formatted string

[NSString stringWithFormat: @"<#string#>", <#param1#>]
Something went wrong with that request. Please try again.