mirror of
https://github.com/gryf/snipmate.vim.git
synced 2025-12-19 20:38:05 +01:00
Completely replaced command-based snippets with a new, easier to read/maintain syntax. Also added a python script to make it easier to migrate.
This commit is contained in:
122
snippets/objc.snippets
Normal file
122
snippets/objc.snippets
Normal file
@@ -0,0 +1,122 @@
|
||||
# #import <...>
|
||||
snippet imp
|
||||
#import <${1:Cocoa/Cocoa.h}>${2}
|
||||
# #import "..."
|
||||
snippet Imp
|
||||
#import "${1:`Filename()`.h}"${2}
|
||||
# @selector(...)
|
||||
snippet sel
|
||||
@selector(${1:method}:)${3}
|
||||
# NSLog(...)
|
||||
snippet log
|
||||
NSLog(@"${1}"${2});${3}
|
||||
# Class
|
||||
snippet objc
|
||||
@interface ${1:`Filename('', 'object')`} : ${2:NSObject}
|
||||
{
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation $1
|
||||
- (id) init
|
||||
{
|
||||
if (self = [super init])
|
||||
# Class Interface
|
||||
snippet clh
|
||||
@interface ${1:ClassName} : ${2:NSObject}
|
||||
{${3}
|
||||
}
|
||||
${4}
|
||||
@end
|
||||
snippet ibo
|
||||
IBOutlet ${1:NSSomeClass} *${2:$1};
|
||||
# Category
|
||||
snippet cat
|
||||
@interface ${1:NSObject} (${2:Category})
|
||||
@end
|
||||
|
||||
@implementation $1 ($2)
|
||||
${3}
|
||||
@end
|
||||
# Category Interface
|
||||
snippet cath
|
||||
@interface ${1:NSObject} (${2:Category})
|
||||
${3}
|
||||
@end
|
||||
# NSArray
|
||||
snippet array
|
||||
NSMutableArray *${1:array} = [NSMutable array];${2}
|
||||
# NSDictionary
|
||||
snippet dict
|
||||
NSMutableDictionary *${1:dict} = [NSMutableDictionary dictionary];${2}
|
||||
# NSBezierPath
|
||||
snippet bez
|
||||
NSBezierPath *${1:path} = [NSBezierPath bezierPath];${2}
|
||||
# Method
|
||||
snippet m
|
||||
- (${1:id})${2:method}
|
||||
{
|
||||
${3:return self;}
|
||||
}
|
||||
# Method declaration
|
||||
snippet md
|
||||
- (${1:id})${2:method};${3}
|
||||
# Class Method
|
||||
snippet M
|
||||
+ (${1:id})${2:method}
|
||||
{${3}
|
||||
return nil;
|
||||
}
|
||||
# Sub-method (Call super)
|
||||
snippet sm
|
||||
- (${1:id})${2:method}
|
||||
{
|
||||
[super $2];${3}
|
||||
return self;
|
||||
}
|
||||
# Method: Initialize
|
||||
snippet I
|
||||
+ (void) initialize
|
||||
{
|
||||
[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWIthObjectsAndKeys:
|
||||
${1}@"value", @"key",
|
||||
nil]];
|
||||
}
|
||||
# Accessor Methods For:
|
||||
# Object
|
||||
snippet objacc
|
||||
- (${1:id})${2:thing}
|
||||
{
|
||||
return $2;
|
||||
}
|
||||
|
||||
- (void) set$2:($1)
|
||||
{
|
||||
$1 old$2 = $2;
|
||||
$2 = [aValue retain];
|
||||
[old$2 release];
|
||||
}
|
||||
snippet forarray
|
||||
unsigned int ${1:object}Count = [${2:array} count];
|
||||
|
||||
for (unsigned int index = 0; index < $1Count; index++)
|
||||
{
|
||||
${3:id} $1 = [$2 $1AtIndex:index];
|
||||
${4}
|
||||
}
|
||||
# IBOutlet
|
||||
# @property (Objective-C 2.0)
|
||||
snippet prop
|
||||
@property (${1:retain}) ${2:NSSomeClass} *${3:$2};${4}
|
||||
# @synthesize (Objective-C 2.0)
|
||||
snippet syn
|
||||
@synthesize ${1:NSSomeClass};${2}
|
||||
# [[ alloc] init]
|
||||
snippet alloc
|
||||
[[${1:foo} alloc] init]${2};${3}
|
||||
# retain
|
||||
snippet ret
|
||||
[${1:foo} retain];${2}
|
||||
# release
|
||||
snippet rel
|
||||
[${1:foo} release];${2}
|
||||
Reference in New Issue
Block a user