mirror of
https://github.com/joaotavora/yasnippet.git
synced 2026-02-04 22:42:25 +00:00
adding objc-snippets
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: objacc
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Object
|
||||
## condition: "(source.objc | source.objc++) & meta.scope.implementation.objc - meta.function-with-body"
|
||||
# --
|
||||
- (${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];
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: cdacc
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: CoreData
|
||||
## condition: "source.objc, source.objc++"
|
||||
# --
|
||||
- (${1:id})${2:attribute}
|
||||
{
|
||||
[self willAccessValueForKey:@"${2: attribute}"];
|
||||
${1:id} value = [self primitiveValueForKey:@"${2: attribute}"];
|
||||
[self didAccessValueForKey:@"${2: attribute}"];
|
||||
return value;
|
||||
}
|
||||
|
||||
- (void)set${2/./\u$0/}:($1)aValue
|
||||
{
|
||||
[self willChangeValueForKey:@"${2: attribute}"];
|
||||
[self setPrimitiveValue:aValue forKey:@"${2: attribute}"];
|
||||
[self didChangeValueForKey:@"${2: attribute}"];
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: arracc
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: KVC Array
|
||||
## condition: "(source.objc | source.objc++) & meta.scope.implementation.objc - meta.function-with-body"
|
||||
# --
|
||||
- (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${TM_C_POINTER/(^(.+?)\s*$)?/(?1:$2: *)/})${1/./\l$0/}
|
||||
{
|
||||
return $3;
|
||||
}
|
||||
|
||||
- (void)set$1:(NSArray${TM_C_POINTER/(^(.+?)\s*$)?/(?1:$2: *)/})new$1
|
||||
{
|
||||
[$3 setArray:new$1];
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: prop
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Property (Objective-C 2.0)
|
||||
## condition: "source.objc meta.scope.interface, source.objc++ meta.scope.interface"
|
||||
# --
|
||||
@property (${1/^(e)$|.*/(?1:r)/}${1:r}${1/^(?:(r)|(e)|(c)|(a))$|.*/(?1:etain)(?2:adonly)(?3:opy)(?4:ssign)/}) ${2:NSSomeClass}${TM_C_POINTER: *}${3:${2/^[A-Z](?:[A-Z]+|[a-z]+)([A-Z]\w*)/\l$1/}};
|
||||
@@ -0,0 +1,15 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: acc
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Primitive Type
|
||||
## condition: "(source.objc | source.objc++) & meta.scope.implementation.objc - meta.function-with-body"
|
||||
# --
|
||||
- (${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/};
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: stracc
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: String
|
||||
## condition: "(source.objc | source.objc++) & meta.scope.implementation.objc - meta.function-with-body"
|
||||
# --
|
||||
- (NSString${TM_C_POINTER/(^(.+?)\s*$)?/(?1:$2: *)/})${1:thing}
|
||||
{
|
||||
return ${2:$1};
|
||||
}
|
||||
|
||||
- (void)set${1/.*/\u$0/}:(NSString${TM_C_POINTER/(^(.+?)\s*$)?/(?1:$2: *)/})${3:a${1/.*/\u$0/}}
|
||||
{
|
||||
$3 = [$3 copy];
|
||||
[$2 release];
|
||||
$2 = $3;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
# -*- mode: snippet -*-
|
||||
# key: syn
|
||||
# contributor: Translated from TextMate Snippet
|
||||
# name: Synthesize Property
|
||||
## condition: "(source.objc | source.objc++) & meta.scope.implementation.objc - meta.function-with-body"
|
||||
# --
|
||||
@synthesize ${1:property};
|
||||
Reference in New Issue
Block a user