neosnippet.vim/autoload/neosnippet/snippets/objc.snip

334 lines
5.8 KiB
Plaintext
Raw Normal View History

2012-02-02 04:33:35 +00:00
snippet sel
2012-10-30 08:53:14 +00:00
@selector(${1:#:method}:)
2012-02-02 04:33:35 +00:00
snippet imp
#import <${1:Cocoa/Cocoa.h}>
snippet Imp
#import "${1}}"
snippet log
abbr NSLog(...)
NSLog(@"${1}")
snippet cl
abbr Class
@interface ${1} : ${2:NSObject}
{
}
@end
@implementation ${1}
- (id)init
{
if((self = [super init]))
{${0}
}
return self;
}
@end
snippet cli
abbr ClassInterface
@interface ${1} : ${2:NSObject}
{${3}
}
${0}
@end
snippet clm
abbr ClassImplementation
@implementation ${1:object}
- (id)init
{
if((self = [super init]))
{${0}
}
return self;
}
@end
snippet cat
abbr Category
@interface ${1:NSObject} (${2:Category})
@end
@implementation ${1} (${2})
${0}
@end
snippet cati
abbr CategoryInterface
@interface ${1:NSObject)} (${2:Category)})
${0}
@end
snippet array
2012-10-30 08:53:14 +00:00
NSMutableArray *${1:#:array} = [NSMutableArray array];
2012-02-02 04:33:35 +00:00
snippet dict
2012-10-30 08:53:14 +00:00
NSMutableDictionary *${1:#:dict} = [NSMutableDictionary dictionary];
2012-02-02 04:33:35 +00:00
snippet bez
2012-10-30 08:53:14 +00:00
NSBezierPath *${1:#:path} = [NSBezierPath bezierPath];
2012-02-02 04:33:35 +00:00
snippet m
abbr Method
2012-10-30 08:53:14 +00:00
- (${1:#:id})${2:#:method}${3:(#:id)}${4:#:anArgument}
2012-02-02 04:33:35 +00:00
{
2012-10-30 08:53:14 +00:00
${0}
2012-02-02 04:33:35 +00:00
return nil;
}
snippet M
abbr Method
2012-10-30 08:53:14 +00:00
- (${1:#:id})${2:#:method}${3:(#:id)}${4:#:anArgument};
2012-02-02 04:33:35 +00:00
snippet cm
abbr ClassMethod
2012-10-30 08:53:14 +00:00
+ (${1:#:id})${2:#:method}${3:(#:id)}${4:#:anArgument}
2012-02-02 04:33:35 +00:00
{
2012-10-30 08:53:14 +00:00
${0}
2012-02-02 04:33:35 +00:00
return nil;
}
snippet icm
abbr InterfaceClassMethod
2012-10-30 08:53:14 +00:00
+ (${1:#:id})${0:#:method};
2012-02-02 04:33:35 +00:00
snippet sm
abbr SubMethod
2012-10-30 08:53:14 +00:00
- (${1:#:id})${2:#:method}${3:(#:id)}${4:#:anArgument}
2012-02-02 04:33:35 +00:00
{
2012-10-30 08:53:14 +00:00
${1} res = [super ${2:#:method}]
2012-02-02 04:33:35 +00:00
return res;
}
snippet mi
abbr MethodInitialize
+ (void)initialize
{
[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
${0}@"value", @"key",
nil]];
}
snippet obj
2012-10-30 08:53:14 +00:00
- (${1:#:id})${2:#:thing}
2012-02-02 04:33:35 +00:00
{
return ${2};
}
- (void)set${2}:(${1})aValue
{
${0}${1}old${2} = ${2};
${2} = [aValue retain];
[old${2} release];
}
snippet iobj
2012-10-30 08:53:14 +00:00
- (${1:#:id})${2:#:thing};
2012-02-02 04:33:35 +00:00
- (void)set${2}:(${1})aValue;
snippet str
2012-10-30 08:53:14 +00:00
- (NSString${$1: *)})${1:#:thing}
2012-02-02 04:33:35 +00:00
{
return ${2};
}
- (void)set${1}:(NSString${2: *})${3}
{
${3} = [${3} copy];
[${2} release];
${2} = ${3};
}
snippet istr
2012-10-30 08:53:14 +00:00
- (NSString${1: *)}${1:#:thing};
2012-02-02 04:33:35 +00:00
- (void)set${1}:(NSString${2: *})${2};
snippet cd
abbr CoreData
2012-10-30 08:53:14 +00:00
- (${1:#:id})${2:#:attribute}
2012-02-02 04:33:35 +00:00
{
2012-10-30 08:53:14 +00:00
[self willAccessValueForKey:@"$2"];
$1 value = [self primitiveValueForKey:@"$2"];
[self didAccessValueForKey:@"$2"];
2012-02-02 04:33:35 +00:00
return value;
}
2012-10-30 08:53:14 +00:00
- (void)set$2:($1)aValue
2012-02-02 04:33:35 +00:00
{
2012-10-30 08:53:14 +00:00
[self willChangeValueForKey:@"$2"];
[self setPrimitiveValue:aValue forKey:@"$2"];
[self didChangeValueForKey:@"$2"];
2012-02-02 04:33:35 +00:00
}
snippet karray
abbr KVCArry
2012-10-30 08:53:14 +00:00
- (void)addObjectTo${1:#:Things}:(${2:#:id})anObject
2012-02-02 04:33:35 +00:00
{
[${3}} addObject:anObject];
}
2012-10-30 08:53:14 +00:00
- (void)insertObject:($2)anObject in$1AtIndex:(unsigned int)i
2012-02-02 04:33:35 +00:00
{
[${3} insertObject:anObject atIndex:i];
}
- (${2})objectIn${1}AtIndex:(unsigned int)i
{
return [${3} objectAtIndex:i];
}
- (unsigned int)indexOfObjectIn${1}:(${2})anObject
{
return [${3} indexOfObject:anObject];
}
- (void)removeObjectFrom${1}AtIndex:(unsigned int)i
{
[${3} removeObjectAtIndex:i];
}
- (unsigned int)countOf${1}
{
return [${3} count];
}
- (NSArray${4: *}${1}
{
return ${3}
}
- (void)set${1}:(NSArray${4: *})new${1}
{
[${3} setArray:new${1}];
}
snippet iarray
abbr InterfaceAccessorsForKVCArray
2012-10-30 08:53:14 +00:00
- (void)addObjectTo${1:#:Things}:(${2:#:id})anObject;
2012-02-02 04:33:35 +00:00
- (void)insertObject:(${2})anObject in${1}AtIndex:(unsigned int)i;
- (${2})objectIn${1}AtIndex:(unsigned int)i;
- (unsigned int)indexOfObjectIn${1}:(${2})anObject;
- (void)removeObjectFrom${1}AtIndex:(unsigned int)i;
- (unsigned int)countOf${1};
- (NSArray${3: *})${1};
- (void)set${1}:(NSArray${3: *})new${1};
snippet acc
abbr PrimitiveType
2012-10-30 08:53:14 +00:00
- (${1:unsigned int})${2:#:thing}
2012-02-02 04:33:35 +00:00
{
return ${3};
}
- (void)set${2}:(${1:unsigned int})new${2}
{
${3} = new${2};
}
snippet iacc
abbr Interface:AccessorsForPrimitiveType
- (${1:unsigned int})${2:thing};
- (void)set${2}:($1)new${2};
snippet rdef
abbr ReadDefaultsValue
[[NSUserDefaults standardUserDefaults] objectForKey:${1:key}];
snippet wdef
abbr WriteDefaultsValue
[[NSUserDefaults standardUserDefaults] setObject:${1:object} forKey:${2:key}];
snippet ibo
abbr IBOutlet
IBOutlet ${1}${2: *}${3};
snippet syn
2012-10-30 08:53:14 +00:00
@synthesize ${1:#:property};
2012-02-02 04:33:35 +00:00
snippet bind
2012-10-30 08:53:14 +00:00
bind:@"${2:#:binding}" toObject:${3:observableController} withKeyPath:@"${4:keyPath}" options:${5:nil}
2012-02-02 04:33:35 +00:00
snippet reg
[[NSNotificationCenter defaultCenter] addObserver:${1:self} selector:@selector(${3}) name:${2:NSWindowDidBecomeMainNotification} object:${4:nil}];
snippet focus
[self lockFocus];
${0}
[self unlockFocus];
snippet forarray
unsigned int ${1:object}Count = [${2:array} count];
for(unsigned int index = 0; index < ${1}Count; index += 1)
{
${3:id} ${1} = [${2} objectAtIndex:index];
${0}
}
snippet 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:Continue}"
{
${0};
}
else if(choice == NSAlertAlternateReturn) // "${4:Cancel}"
{
}
snippet res
${1} Send ${2} to ${1}, if ${1} supports it}${3}
if ([${1:self} respondsToSelector:@selector(${2:someSelector:})])
{
[${1} ${3}];
}
snippet del
if([${1:[self delegate]} respondsToSelector:@selector(${2:selfDidSomething:})])
[${1} ${3}];
snippet format
[NSString stringWithFormat:@"${1}", ${2}]${0}
snippet save
[NSGraphicsContext saveGraphicsState];
${0}
[NSGraphicsContext restoreGraphicsState];
snippet thread
2012-10-30 08:53:14 +00:00
[NSThread detachNewThreadSelector:@selector(${1:#:method}:) toTarget:${2:#:aTarget} withObject:${3:#:anArgument}]
2012-02-02 04:33:35 +00:00
snippet pool
NSAutoreleasePool${TM_C_POINTER: *}pool = [NSAutoreleasePool new];
${0}
[pool drain];
2012-10-30 08:53:14 +00:00