1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
{
"Imp": {
"prefix": "Imp",
"description": "#import <> (Imp)",
"body": "#import <${1:Cocoa/Cocoa.h}>"
},
"array": {
"prefix": "array",
"description": "NSArray (array)",
"body": "NSMutableArray *${1:array} = [NSMutableArray array];"
},
"dict": {
"prefix": "dict",
"description": "NSDictionary (dict)",
"body": "NSMutableDictionary *${1:dict} = [NSMutableDictionary dictionary];"
},
"forarray": {
"prefix": "forarray",
"description": "for NSArray loop (forarray)",
"body": [
"unsigned int\t${1:object}Count = [${2:array} count];",
"",
"for(unsigned int index = 0; index < $1Count; index += 1)",
"{",
"\t${3:id}\t$1 = [$2 objectAtIndex:index];",
"\t$0",
"\\}"
]
},
"sel": {
"prefix": "sel",
"description": "@selector",
"body": "@selector(${1:method}:)"
},
"thread": {
"prefix": "thread",
"description": "Detach New NSThread",
"body": "[NSThread detachNewThreadSelector:@selector(${1:method}:) toTarget:${2:aTarget} withObject:${3:anArgument}]"
},
"I": {
"prefix": "I",
"description": "Initialize Implementation (I)",
"body": [
"+ (void)initialize",
"{",
"\t[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:",
"\t\t$0@\"value\", @\"key\",",
"\t\tnil]];",
"\\}"
]
},
"bind": {
"prefix": "bind",
"description": "Key:value binding (bind)",
"body": "bind:@\"${1:binding}\" toObject:${2:observableController} withKeyPath:@\"${3:keyPath}\" options:${4:nil}"
},
"focus": {
"prefix": "focus",
"description": "Lock Focus",
"body": [
"[self lockFocus];",
"$0",
"[self unlockFocus];"
]
},
"pool": {
"prefix": "pool",
"description": "NSAutoreleasePool (pool)",
"body": [
"NSAutoreleasePool *pool = [NSAutoreleasePool new];",
"$0",
"[pool drain];"
]
},
"alert": {
"prefix": "alert",
"description": "NSRunAlertPanel (alert)",
"body": [
"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\"",
"{",
"\t$0;",
"\\}",
"else if(choice == NSAlertAlternateReturn) // \"$4\"",
"{",
"\t\t$0",
"\\}"
]
},
"format": {
"prefix": "format",
"description": "NSString stringWithFormat (format)",
"body": "[NSString stringWithFormat:@\"$1\", $2]$0"
},
"getprefs": {
"prefix": "getprefs",
"description": "Read from defaults (getprefs)",
"body": "[[NSUserDefaults standardUserDefaults] objectForKey:${1:key}];"
},
"gsave": {
"prefix": "gsave",
"description": "Save and Restore Graphics Context (gsave)",
"body": [
"[NSGraphicsContext saveGraphicsState];",
"$0",
"[NSGraphicsContext restoreGraphicsState];",
""
]
},
"syn": {
"prefix": "syn",
"description": "Synthesize",
"body": "@synthesize ${1:property};"
},
"setprefs": {
"prefix": "setprefs",
"description": "Write to defaults (setprefs)",
"body": "[[NSUserDefaults standardUserDefaults] setObject:${1:object} forKey:${2:key}];"
}
}
|