Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

updated objc snippets

  • Loading branch information...
commit af264e857f16fa90741452fb4cd64403970a51b7 1 parent ddd6b8f
Michael Sanders msanders authored

Showing 1 changed file with 33 additions and 24 deletions. Show diff stats Hide diff stats

  1. +33 24 snippets/objc.snippets
57 snippets/objc.snippets
... ... @@ -1,8 +1,8 @@
1 1 # #import <...>
2   -snippet imp
  2 +snippet Imp
3 3 #import <${1:Cocoa/Cocoa.h}>${2}
4 4 # #import "..."
5   -snippet Imp
  5 +snippet imp
6 6 #import "${1:`Filename()`.h}"${2}
7 7 # @selector(...)
8 8 snippet sel
@@ -12,26 +12,26 @@ snippet s
12 12 @"${1}"${2}
13 13 # Object
14 14 snippet o
15   - ${1:NSObject} *${2:foo} = [${3:$1 alloc}];${5}
  15 + ${1:NSObject} *${2:foo} = [${3:$1 alloc}]${4};${5}
16 16 # NSLog(...)
17 17 snippet log
18   - NSLog(@"${1}"${2});${3}
  18 + NSLog(@"${1:%@}"${2});${3}
19 19 # Class
20 20 snippet objc
21 21 @interface ${1:`Filename('', 'someClass')`} : ${2:NSObject}
22 22 {
23 23 }
24 24 @end
25   -
  25 +
26 26 @implementation $1
27 27 ${3}
28 28 @end
29 29 # Class Interface
30 30 snippet int
31   - @interface ${1:`Filename('', 'someClass')`}
32   - {${2}
  31 + @interface ${1:`Filename('', 'someClass')`} : ${2:NSObject}
  32 + {${3}
33 33 }
34   - ${3}
  34 + ${4}
35 35 @end
36 36 # Class Implementation
37 37 snippet impl
@@ -41,18 +41,21 @@ snippet impl
41 41 snippet init
42 42 - (id)init
43 43 {
44   - if ((self = [super init]))
45   - {${1}
46   - }
  44 + [super init];
47 45 return self;
48 46 }
  47 +snippet ifself
  48 + if (self = [super init]) {
  49 + ${1:/* code */}
  50 + }
  51 + return self;
49 52 snippet ibo
50 53 IBOutlet ${1:NSSomeClass} *${2:$1};${3}
51 54 # Category
52 55 snippet cat
53 56 @interface ${1:NSObject} (${2:Category})
54 57 @end
55   -
  58 +
56 59 @implementation $1 ($2)
57 60 ${3}
58 61 @end
@@ -74,19 +77,19 @@ snippet bez
74 77 snippet m
75 78 - (${1:id})${2:method}
76 79 {
77   - ${3:return self;}
  80 + ${3}
78 81 }
79 82 # Method declaration
80 83 snippet md
81 84 - (${1:id})${2:method};${3}
82 85 # IBAction declaration
83 86 snippet ibad
84   - - (IBAction)${1:method};${2}
  87 + - (IBAction)${1:method}:(${2:id})sender;${3}
85 88 # IBAction method
86 89 snippet iba
87   - - (IBAction)${1:method}
  90 + - (IBAction)${1:method}:(${2:id})sender
88 91 {
89   - ${2}
  92 + ${3}
90 93 }
91 94 # awakeFromNib method
92 95 snippet wake
@@ -122,7 +125,7 @@ snippet objacc
122 125 {
123 126 return $2;
124 127 }
125   -
  128 +
126 129 - (void)set$2:($1)${3:new$2}
127 130 {
128 131 [$3 retain];
@@ -130,13 +133,13 @@ snippet objacc
130 133 $2 = $3;
131 134 }${4}
132 135 # for (object in array)
133   -snippet fora
134   - for (${1:Class} *${2:Object} in ${3:array}) {
  136 +snippet forin
  137 + for (${1:Class} *${2:some$1} in ${3:array}) {
135 138 ${4}
136 139 }
137 140 snippet forarray
138 141 unsigned int ${1:object}Count = [${2:array} count];
139   -
  142 +
140 143 for (unsigned int index = 0; index < $1Count; index++) {
141 144 ${3:id} $1 = [$2 $1AtIndex:index];
142 145 ${4}
@@ -144,20 +147,20 @@ snippet forarray
144 147 # IBOutlet
145 148 # @property (Objective-C 2.0)
146 149 snippet prop
147   - @property (${1:retain}) ${2:NSSomeClass} *${3:$2};${4}
  150 + @property (${1:retain}) ${2:NSSomeClass} ${3:*$2};${4}
148 151 # @synthesize (Objective-C 2.0)
149 152 snippet syn
150 153 @synthesize ${1:property};${2}
151 154 # [[ alloc] init]
152 155 snippet alloc
153   - [[${1:foo} alloc] init]${2};${3}
  156 + [[${1:foo} alloc] init${2}];${3}
154 157 # retain
155 158 snippet ret
156 159 [${1:foo} retain];${2}
157 160 # release
158 161 snippet rel
159 162 [${1:foo} release];
160   - ${2:$1 = nil;}
  163 + ${2:$1 = nil;}
161 164 # autorelease
162 165 snippet arel
163 166 [${1:foo} autorelease];
@@ -165,7 +168,7 @@ snippet arel
165 168 snippet pool
166 169 NSAutoreleasePool *${1:pool} = [[NSAutoreleasePool alloc] init];
167 170 ${2:/* code */}
168   - [$1 release];
  171 + [$1 drain];
169 172 # Throw an exception
170 173 snippet except
171 174 NSException *${1:badness};
@@ -173,3 +176,9 @@ snippet except
173 176 reason:@"${3}"
174 177 userInfo:nil];
175 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];

0 comments on commit af264e8

Please sign in to comment.
Something went wrong with that request. Please try again.