]> git.r.bdr.sh - rbdr/dotfiles/blame_incremental - vim/snippets/objc.snippets
Update vim plugins
[rbdr/dotfiles] / vim / snippets / objc.snippets
... / ...
CommitLineData
1# #import <...>
2snippet Imp
3 #import <${1:Cocoa/Cocoa.h}>${2}
4# #import "..."
5snippet imp
6 #import "${1:`Filename()`.h}"${2}
7# @selector(...)
8snippet sel
9 @selector(${1:method}:)${3}
10# @"..." string
11snippet s
12 @"${1}"${2}
13# Object
14snippet o
15 ${1:NSObject} *${2:foo} = [${3:$1 alloc}]${4};${5}
16# NSLog(...)
17snippet log
18 NSLog(@"${1:%@}"${2});${3}
19# Class
20snippet objc
21 @interface ${1:`Filename('', 'someClass')`} : ${2:NSObject}
22 {
23 }
24 @end
25
26 @implementation $1
27 ${3}
28 @end
29# Class Interface
30snippet int
31 @interface ${1:`Filename('', 'someClass')`} : ${2:NSObject}
32 {${3}
33 }
34 ${4}
35 @end
36snippet @interface
37 @interface ${1:`Filename('', 'someClass')`} : ${2:NSObject}
38 {${3}
39 }
40 ${4}
41 @end
42# Class Implementation
43snippet impl
44 @implementation ${1:`Filename('', 'someClass')`}
45 ${2}
46 @end
47snippet @implementation
48 @implementation ${1:`Filename('', 'someClass')`}
49 ${2}
50 @end
51# Protocol
52snippet pro
53 @protocol ${1:`Filename('$1Delegate', 'MyProtocol')`} ${2:<NSObject>}
54 ${3}
55 @end
56snippet @protocol
57 @protocol ${1:`Filename('$1Delegate', 'MyProtocol')`} ${2:<NSObject>}
58 ${3}
59 @end
60# init Definition
61snippet init
62 - (id)init
63 {
64 if (self = [super init]) {
65 ${1}
66 }
67 return self;
68 }
69# dealloc Definition
70snippet dealloc
71 - (void) dealloc
72 {
73 ${1:deallocations}
74 [super dealloc];
75 }
76snippet su
77 [super ${1:init}]${2}
78snippet ibo
79 IBOutlet ${1:NSSomeClass} *${2:$1};${3}
80# Category
81snippet cat
82 @interface ${1:NSObject} (${2:MyCategory})
83 @end
84
85 @implementation $1 ($2)
86 ${3}
87 @end
88# Category Interface
89snippet cath
90 @interface ${1:`Filename('$1', 'NSObject')`} (${2:MyCategory})
91 ${3}
92 @end
93# Method
94snippet m
95 - (${1:id})${2:method}
96 {
97 ${3}
98 }
99# Method declaration
100snippet md
101 - (${1:id})${2:method};${3}
102# IBAction declaration
103snippet ibad
104 - (IBAction)${1:method}:(${2:id})sender;${3}
105# IBAction method
106snippet iba
107 - (IBAction)${1:method}:(${2:id})sender
108 {
109 ${3}
110 }
111# awakeFromNib method
112snippet wake
113 - (void)awakeFromNib
114 {
115 ${1}
116 }
117# Class Method
118snippet M
119 + (${1:id})${2:method}
120 {
121 ${3:return nil;}
122 }
123# Sub-method (Call super)
124snippet sm
125 - (${1:id})${2:method}
126 {
127 [super $2];${3}
128 return self;
129 }
130# Accessor Methods For:
131# Object
132snippet objacc
133 - (${1:id})${2:thing}
134 {
135 return $2;
136 }
137
138 - (void)set$2:($1)${3:new$2}
139 {
140 [$3 retain];
141 [$2 release];
142 $2 = $3;
143 }${4}
144# for (object in array)
145snippet forin
146 for (${1:Class} *${2:some$1} in ${3:array}) {
147 ${4}
148 }
149snippet fore
150 for (${1:object} in ${2:array}) {
151 ${3:statements}
152 }
153snippet forarray
154 unsigned int ${1:object}Count = [${2:array} count];
155
156 for (unsigned int index = 0; index < $1Count; index++) {
157 ${3:id} $1 = [$2 $1AtIndex:index];
158 ${4}
159 }
160snippet fora
161 unsigned int ${1:object}Count = [${2:array} count];
162
163 for (unsigned int index = 0; index < $1Count; index++) {
164 ${3:id} $1 = [$2 $1AtIndex:index];
165 ${4}
166 }
167# Try / Catch Block
168snippet @try
169 @try {
170 ${1:statements}
171 }
172 @catch (NSException * e) {
173 ${2:handler}
174 }
175 @finally {
176 ${3:statements}
177 }
178snippet @catch
179 @catch (${1:exception}) {
180 ${2:handler}
181 }
182snippet @finally
183 @finally {
184 ${1:statements}
185 }
186# IBOutlet
187# @property (Objective-C 2.0)
188snippet prop
189 @property (${1:retain}) ${2:NSSomeClass} ${3:*$2};${4}
190# @synthesize (Objective-C 2.0)
191snippet syn
192 @synthesize ${1:property};${2}
193# [[ alloc] init]
194snippet alloc
195 [[${1:foo} alloc] init${2}];${3}
196snippet a
197 [[${1:foo} alloc] init${2}];${3}
198# retain
199snippet ret
200 [${1:foo} retain];${2}
201# release
202snippet rel
203 [${1:foo} release];
204# autorelease
205snippet arel
206 [${1:foo} autorelease];
207# autorelease pool
208snippet pool
209 NSAutoreleasePool *${1:pool} = [[NSAutoreleasePool alloc] init];
210 ${2:/* code */}
211 [$1 drain];
212# Throw an exception
213snippet except
214 NSException *${1:badness};
215 $1 = [NSException exceptionWithName:@"${2:$1Name}"
216 reason:@"${3}"
217 userInfo:nil];
218 [$1 raise];
219snippet prag
220 #pragma mark ${1:-}
221snippet cl
222 @class ${1:Foo};${2}
223snippet color
224 [[NSColor ${1:blackColor}] set];
225# NSArray
226snippet array
227 NSMutableArray *${1:array} = [NSMutable array];${2}
228snippet nsa
229 NSArray ${1}
230snippet nsma
231 NSMutableArray ${1}
232snippet aa
233 NSArray * array;${1}
234snippet ma
235 NSMutableArray * array;${1}
236# NSDictionary
237snippet dict
238 NSMutableDictionary *${1:dict} = [NSMutableDictionary dictionary];${2}
239snippet nsd
240 NSDictionary ${1}
241snippet nsmd
242 NSMutableDictionary ${1}
243# NSString
244snippet nss
245 NSString ${1}
246snippet nsms
247 NSMutableString ${1}