/usr/share/vim/addons/UltiSnips/objc.snippets is in vim-snippets 1.0.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | priority -50
###########################################################################
# TextMate Snippets #
###########################################################################
snippet imp "#import (imp)" b
#import "${1:`!p snip.rv = re.sub(r'\..*$', '.h', fn)`}"
endsnippet
snippet Imp "#import <> (Imp)"
#import <${1:Cocoa/Cocoa.h}>
endsnippet
snippet cl "020 Class (objc)"
@interface ${1:`!p
if len(fn):
snip.rv = re.sub(r'\..*$', '', fn)
else:
snip.rv = "object"
`} : ${2:NSObject}
{
}
@end
@implementation $1
- (id)init
{
if((self = [super init]))
{$0
}
return self;
}
@end
endsnippet
snippet array "NSArray (array)"
NSMutableArray *${1:array} = [NSMutableArray array];
endsnippet
snippet dict "NSDictionary (dict)"
NSMutableDictionary *${1:dict} = [NSMutableDictionary dictionary];
endsnippet
snippet forarray "for NSArray loop (forarray)"
unsigned int ${1:object}Count = [${2:array} count];
for(unsigned int index = 0; index < $1Count; index += 1)
{
${3:id} $1 = [$2 objectAtIndex:index];
$0
}
endsnippet
snippet objacc "Object Accessors (objacc)"
- (${1:id})${2:thing}
{
return $2;
}
- (void)set${2/./\u$0/}:($1)aValue
{
$0${1/( \*)?$/(?1:$1: )/}old${2/./\u$0/} = $2;
$2 = [aValue retain];
[old${2/./\u$0/} release];
}
endsnippet
snippet sel "@selector"
@selector(${1:method}:)
endsnippet
snippet cdacc "CoreData Accessors Implementation"
- (${1:id})${2:attribute}
{
[self willAccessValueForKey:@"$2"];
$1 value = [self primitiveValueForKey:@"$2"];
[self didAccessValueForKey:@"$2"];
return value;
}
- (void)set${2/./\u$0/}:($1)aValue
{
[self willChangeValueForKey:@"$2"];
[self setPrimitiveValue:aValue forKey:@"$2"];
[self didChangeValueForKey:@"$2"];
}
endsnippet
snippet delegate "Delegate Responds to Selector"
if([${1:[self delegate]} respondsToSelector:@selector(${2:selfDidSomething:})])
[$1 ${3:${2/((^\s*([A-Za-z0-9_]*:)\s*)|(:\s*$)|(:\s*))/(?2:$2self :\:<>)(?4::)(?5: :)/g}}];
endsnippet
snippet thread "Detach New NSThread"
[NSThread detachNewThreadSelector:@selector(${1:method}:) toTarget:${2:aTarget} withObject:${3:anArgument}]
endsnippet
snippet ibo "IBOutlet (ibo)"
IBOutlet ${1:NSSomeClass} *${2:${1/^[A-Z](?:[A-Z]+|[a-z]+)([A-Z]\w*)/\l$1/}};
endsnippet
snippet I "Initialize Implementation (I)"
+ (void)initialize
{
[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
$0@"value", @"key",
nil]];
}
endsnippet
snippet bind "Key:value binding (bind)"
bind:@"${1:binding}" toObject:${2:observableController} withKeyPath:@"${3:keyPath}" options:${4:nil}
endsnippet
snippet arracc "LoD array (arracc)"
- (void)addObjectTo${1:Things}:(${2:id})anObject
{
[${3:${1/./\l$0/}} addObject:anObject];
}
- (void)insertObject:($2)anObject in$1AtIndex:(unsigned int)i
{
[$3 insertObject:anObject atIndex:i];
}
- ($2)objectIn$1AtIndex:(unsigned int)i
{
return [$3 objectAtIndex:i];
}
- (unsigned int)indexOfObjectIn$1:($2)anObject
{
return [$3 indexOfObject:anObject];
}
- (void)removeObjectFrom$1AtIndex:(unsigned int)i
{
[$3 removeObjectAtIndex:i];
}
- (unsigned int)countOf$1
{
return [$3 count];
}
- (NSArray *${1/./\l$0/}
{
return $3;
}
- (void)set$1:(NSArray *)new$1
{
[$3 setArray:new$1];
}
endsnippet
snippet arracc "LoD array interface (arracc)"
- (void)addObjectTo${1:Things}:(${2:id})anObject;
- (void)insertObject:($2)anObject in$1AtIndex:(unsigned int)i;
- ($2)objectIn$1AtIndex:(unsigned int)i;
- (unsigned int)indexOfObjectIn$1:($2)anObject;
- (void)removeObjectFrom$1AtIndex:(unsigned int)i;
- (unsigned int)countOf$1;
- (NSArray *)${1/./\l$0/};
- (void)set$1:(NSArray *)new$1;
endsnippet
snippet focus "Lock Focus"
[self lockFocus];
$0
[self unlockFocus];
endsnippet
snippet pool "NSAutoreleasePool (pool)"
NSAutoreleasePool *pool = [NSAutoreleasePool new];
$0
[pool drain];
endsnippet
snippet log "NSLog (log) 2"
NSLog(@"$1"${1/[^%]*(%)?.*/(?1:, :\);)/}$2${1/[^%]*(%)?.*/(?1:\);)/}
endsnippet
snippet alert "NSRunAlertPanel (alert)"
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"
{
$0;
}
else if(choice == NSAlertAlternateReturn) // "$4"
{
$0
}
endsnippet
snippet format "NSString stringWithFormat (format)"
[NSString stringWithFormat:@"$1", $2]$0
endsnippet
snippet objacc "Object Accessors Interface (objacc)"
- (${1:id})${2:thing};
- (void)set${2/./\u$0/}:($1)aValue;
endsnippet
snippet prop "Property"
@property (${1/^(e)$|.*/(?1:r)/}${1:r}${1/^(?:(r)|(e)|(c)|(a))$|.*/(?1:etain)(?2:adonly)(?3:opy)(?4:ssign)/}) ${2:NSSomeClass}$ *${3:${2/^[A-Z](?:[A-Z]+|[a-z]+)([A-Z]\w*)/\l$1/}};
endsnippet
snippet getprefs "Read from defaults (getprefs)"
[[NSUserDefaults standardUserDefaults] objectForKey:${1:key}];
endsnippet
snippet obs "Register for Notification"
[[NSNotificationCenter defaultCenter] addObserver:${1:self} selector:@selector(${3:${2/^([A-Z]{2})?(.+?)(Notification)?$/\l$2/}}:) name:${2:NSWindowDidBecomeMainNotification} object:${4:nil}];
endsnippet
snippet responds "Responds to Selector"
if ([${1:self} respondsToSelector:@selector(${2:someSelector:})])
{
[$1 ${3:${2/((:\s*$)|(:\s*))/:<>(?3: )/g}}];
}
endsnippet
snippet gsave "Save and Restore Graphics Context (gsave)"
[NSGraphicsContext saveGraphicsState];
$0
[NSGraphicsContext restoreGraphicsState];
endsnippet
snippet acc "Scalar Accessors (acc)"
- (${1:unsigned int})${2:thing}
{
return ${3:$2};
}
- (void)set${2/./\u$0/}:(${1:unsigned int})new${2/./\u$0/}
{
$3 = new${2/./\u$0/};
}
endsnippet
snippet acc "Scalar Accessors Interface (acc)"
- (${1:unsigned int})${2:thing};
- (void)set${2/./\u$0/}:($1)new${2/./\u$0/};
endsnippet
snippet stracc "String Accessors (stracc)"
- (NSString *)${1:thing}
{
return ${2:$1};
}
- (void)set${1/.*/\u$0/}:(NSString *)/})${3:a${1/.*/\u$0/}}
{
$3 = [$3 copy];
[$2 release];
$2 = $3;
}
endsnippet
snippet syn "Synthesize"
@synthesize ${1:property};
endsnippet
snippet setprefs "Write to defaults (setprefs)"
[[NSUserDefaults standardUserDefaults] setObject:${1:object} forKey:${2:key}];
endsnippet
# vim:ft=snippets:
|