Trying to mimic the alloc live template for new instead

Hi,

I am trying to mimic the live template for alloc where one would type alloc and hit tab and AppCode inserts [[MyObject alloc] init]. I want to make one for new so AppCode completes it to [MyObject new];

My problem is that it only recognizes the correct classnamewhen I have two open square brackets in the beginning of the live templeate like this [[$TYPE$ new];$END$ but this leaves me with noncompiling code since one bracket is to much. So remove the first bracket I thought and now it does not recognize the correct class name any more and inserts just plain NSObject everytime.

Variable $Type" is declared like this: expression: className() default value: "NSObject"

Any hints how I can make my live template work?

2 comments
Comment actions Permalink

This seems to be a bug in the live template that it doesn't suggest the correct type: http://youtrack.jetbrains.com/issue/OC-5405

But, actually, you don't need a live template for it - use smart completion in the assignments:
NSString *s = <press Shift+Ctrl+Space and after that type new>:
Screen Shot 2012-09-20 at 13.29.03 .png
See our blog for more tricks with completion: http://blog.jetbrains.com/objc/category/tipsntricks/

0
Comment actions Permalink

Ok thanks . Always forgetting about smart completion since AppCode does such a good job without smart completion too ;)

0

Please sign in to leave a comment.