CTRLP
[my-vim-dotfolder.git] / snippets / objc.snippets
blob4749bb776205165978ba319b745e6f5e565efd7f
1 # #import <...>
2 snippet Imp
3         #import <${1:Cocoa/Cocoa.h}>${2}
4 # #import "..."
5 snippet imp
6         #import "${1:`Filename()`.h}"${2}
7 # @selector(...)
8 snippet sel
9         @selector(${1:method}:)${3}
10 # @"..." string
11 snippet s
12         @"${1}"${2}
13 # Object
14 snippet o
15         ${1:NSObject} *${2:foo} = [${3:$1 alloc}]${4};${5}
16 # NSLog(...)
17 snippet log
18         NSLog(@"${1:%@}"${2});${3}
19 # Class
20 snippet objc
21         @interface ${1:`Filename('', 'someClass')`} : ${2:NSObject}
22         {
23         }
24         @end
26         @implementation $1
27         ${3}
28         @end
29 # Class Interface
30 snippet int
31         @interface ${1:`Filename('', 'someClass')`} : ${2:NSObject}
32         {${3}
33         }
34         ${4}
35         @end
36 # Class Implementation
37 snippet impl
38         @implementation ${1:`Filename('', 'someClass')`}
39         ${2}
40         @end
41 snippet init
42         - (id)init
43         {
44                 [super init];
45                 return self;
46         }
47 snippet ifself
48         if (self = [super init]) {
49                 ${1:/* code */}
50         }
51         return self;
52 snippet ibo
53         IBOutlet ${1:NSSomeClass} *${2:$1};${3}
54 # Category
55 snippet cat
56         @interface ${1:NSObject} (${2:Category})
57         @end
59         @implementation $1 ($2)
60         ${3}
61         @end
62 # Category Interface
63 snippet cath
64         @interface ${1:NSObject} (${2:Category})
65         ${3}
66         @end
67 # NSArray
68 snippet array
69         NSMutableArray *${1:array} = [NSMutable array];${2}
70 # NSDictionary
71 snippet dict
72         NSMutableDictionary *${1:dict} = [NSMutableDictionary dictionary];${2}
73 # NSBezierPath
74 snippet bez
75         NSBezierPath *${1:path} = [NSBezierPath bezierPath];${2}
76 # Method
77 snippet m
78         - (${1:id})${2:method}
79         {
80                 ${3}
81         }
82 # Method declaration
83 snippet md
84         - (${1:id})${2:method};${3}
85 # IBAction declaration
86 snippet ibad
87         - (IBAction)${1:method}:(${2:id})sender;${3}
88 # IBAction method
89 snippet iba
90         - (IBAction)${1:method}:(${2:id})sender
91         {
92                 ${3}
93         }
94 # awakeFromNib method
95 snippet wake
96         - (void)awakeFromNib
97         {
98                 ${1}
99         }
100 # Class Method
101 snippet M
102         + (${1:id})${2:method}
103         {${3}
104                 return nil;
105         }
106 # Sub-method (Call super)
107 snippet sm
108         - (${1:id})${2:method}
109         {
110                 [super $2];${3}
111                 return self;
112         }
113 # Method: Initialize
114 snippet I
115         + (void) initialize
116         {
117                 [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWIthObjectsAndKeys:
118                         ${1}@"value", @"key",
119                         nil]];
120         }
121 # Accessor Methods For:
122 # Object
123 snippet objacc
124         - (${1:id})${2:thing}
125         {
126                 return $2;
127         }
129         - (void)set$2:($1)${3:new$2}
130         {
131                 [$3 retain];
132                 [$2 release];
133                 $2 = $3;
134         }${4}
135 # for (object in array)
136 snippet forin
137         for (${1:Class} *${2:some$1} in ${3:array}) {
138                 ${4}
139         }
140 snippet forarray
141         unsigned int ${1:object}Count = [${2:array} count];
143         for (unsigned int index = 0; index < $1Count; index++) {
144                 ${3:id} $1 = [$2 $1AtIndex:index];
145                 ${4}
146         }
147 # IBOutlet
148 # @property (Objective-C 2.0)
149 snippet prop
150         @property (${1:retain}) ${2:NSSomeClass} ${3:*$2};${4}
151 # @synthesize (Objective-C 2.0)
152 snippet syn
153         @synthesize ${1:property};${2}
154 # [[ alloc] init]
155 snippet alloc
156         [[${1:foo} alloc] init${2}];${3}
157 # retain
158 snippet ret
159         [${1:foo} retain];${2}
160 # release
161 snippet rel
162         [${1:foo} release];
163         ${2:$1 = nil;}
164 # autorelease
165 snippet arel
166         [${1:foo} autorelease];
167 # autorelease pool
168 snippet pool
169         NSAutoreleasePool *${1:pool} = [[NSAutoreleasePool alloc] init];
170         ${2:/* code */}
171         [$1 drain];
172 # Throw an exception
173 snippet except
174         NSException *${1:badness};
175         $1 = [NSException exceptionWithName:@"${2:$1Name}"
176                                      reason:@"${3}"
177                                    userInfo:nil];
178         [$1 raise];
179 snippet prag
180         #pragma mark ${1:foo}
181 snippet cl
182         @class ${1:Foo};${2}
183 snippet color
184         [[NSColor ${1:blackColor}] set];