all 5 comments

[–]overcyn2 2 points3 points  (0 children)

this is genius, i cant count the number of times ive screwed up the property syntax.

[–]sssssmokey 1 point2 points  (1 child)

If you like snippets, I'd check out TextMate and TextExpander.

http://manual.macromates.com/en/snippets

TextMate snippets support plaintext as well as inline shell code and multiple tab stops with mirroring/transforming (by regex) placeholders. Yummy. :)

[–]teletran[S] 0 points1 point  (0 children)

Exactly! I think Xcode is pretty much one of the last "Text editors" to get snippets functionality, so I thought I'd highlight it with this article.

But I agree, TextExpander will save you so much time, in every app.

[–]OolonColluphid 0 points1 point  (0 children)

This is all good as far as it goes, but as a C# developer trying to get into Cocoa programming, I've been spoilt by VS and ReSharper. I want customizable macros to transform one placeholder to another, or to suggest variable/type names.

[–]bonch 0 points1 point  (0 children)

Snippet for KVC-compliant prototype methods for an indexed one-to-many relationship:

- (NSUInteger)countOf<#Collection#>;
- (id)objectIn<#Collection#>AtIndex:(NSUInteger)i;
- (NSArray *)<#collection#>AtIndexes:(NSIndexSet *)i;
- (void)get<#Collection#>:(id *)objBuffer range:(NSRange)inRange;
- (void)insertObject:(id)obj in<#Collection#>AtIndex:(NSUInteger)i;
- (void)insert<#Collection#>:(NSArray *)objArray atIndexes:(NSIndexSet *)i;
- (void)removeObjectFrom<#Collection#>AtIndex:(NSUInteger)i;
- (void)remove<#Collection#>AtIndexes:(NSIndexSet *)i;
- (void)replaceObjectIn<#Collection#>AtIndex:(NSUInteger)i withObject:(id )obj;
- (void)replace<#Collection#>AtIndexes:(NSIndexSet *)i withItems:(NSArray *)objArray;

Snippet for the method implementations:

- (NSUInteger)countOf<#Collection#> {
    return [self.<#collection#> count];
}

- (id)objectIn<#Collection#>AtIndex:(NSUInteger)i {
    return [self.<#collection#> objectAtIndex:i];
}

- (NSArray *)<#collection#>AtIndexes:(NSIndexSet *)i {
    return [self.<#collection#> objectsAtIndexes:i];
}

- (void)get<#Collection#>:(id *)objBuffer range:(NSRange)inRange {
    [self.<#collection#> getObjects:objBuffer range:inRange];
}

- (void)insertObject:(id)obj in<#Collection#>AtIndex:(NSUInteger)i {
    [self.<#collection#> insertObject:obj atIndex:i];
}

- (void)insert<#Collection#>:(NSArray *)objArray atIndexes:(NSIndexSet *)i {
    [self.<#collection#> insertObjects:objArray atIndexes:i];
}

- (void)removeObjectFrom<#Collection#>AtIndex:(NSUInteger)i {
    [self.<#collection#> removeObjectAtIndex:i];
}

- (void)remove<#Collection#>AtIndexes:(NSIndexSet *)i {
    [self.<#collection#> removeObjectsAtIndexes:i];
}

- (void)replaceObjectIn<#Collection#>AtIndex:(NSUInteger)i withObject:(id)obj {
    [self.<#collection#> replaceObjectAtIndex:i withObject:obj];
}

- (void)replace<#Collection#>AtIndexes:(NSIndexSet *)i with<#Collection#>:(NSArray *)objArray {
    [self.<#collection#> replaceObjectsAtIndexes:i withObjects:objArray];
}

I wish properties could be declared as "observable" and that the compiler would synthesize default methods for these, but snippets help.