adding objc-snippets

This commit is contained in:
capitaomorte
2010-03-14 15:30:22 +00:00
parent c11379e768
commit efa4d6e481
52 changed files with 547 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# key: thread
# contributor: Translated from TextMate Snippet
# name: Detach New NSThread
## condition: "source.objc, source.objc++"
# --
[NSThread detachNewThreadSelector:@selector(${1:method}:) toTarget:${2:aTarget} withObject:${3:anArgument}]

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# key: bind
# contributor: Translated from TextMate Snippet
# name: Bind Property to Key Path of Object
## condition: "source.objc, source.objc++"
# --
bind:@"${2:binding}" toObject:${3:observableController} withKeyPath:@"${4:keyPath}" options:${5:nil}

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# key: log
# contributor: Translated from TextMate Snippet
# name: NSLog(…)
## condition: "source.objc, source.objc++"
# --
NSLog(@"$1"${1/[^%]*(%)?.*/(?1:, :\);)/}$2${1/[^%]*(%)?.*/(?1:\);)/}

View File

@@ -0,0 +1,15 @@
# -*- mode: snippet -*-
# key: alert
# contributor: Translated from TextMate Snippet
# name: NSRunAlertPanel
## condition: "source.objc, source.objc++"
# --
int choice = NSRunAlertPanel(@"${1:Something important!}", @"${2:Something important just happend, and now I need to ask you, do you want to continue?}", @"${3:Continue}", @"${4:Cancel}", nil);
if(choice == NSAlertDefaultReturn) // "${3:Continue}"
{
$0;
}
else if(choice == NSAlertAlternateReturn) // "${4:Cancel}"
{
}

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# key: getprefs
# contributor: Translated from TextMate Snippet
# name: Read Defaults Value
## condition: "source.objc, source.objc++"
# --
[[NSUserDefaults standardUserDefaults] objectForKey:${1:key}];

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# key: obs
# contributor: Translated from TextMate Snippet
# name: Register for Notification
## condition: "source.objc meta.scope.implementation, source.objc++ meta.scope.implementation"
# --
[[NSNotificationCenter defaultCenter] addObserver:${1:self} selector:@selector(${3:${2/^([A-Z]{2})?(.+?)(Notification)?$/\l$2/}}:) name:${2:NSWindowDidBecomeMainNotification} object:${4:nil}];

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# key: setprefs
# contributor: Translated from TextMate Snippet
# name: Write Defaults Value
## condition: "source.objc, source.objc++"
# --
[[NSUserDefaults standardUserDefaults] setObject:${1:object} forKey:${2:key}];