This template let's you easily implement a property getter like this:
- (UIView *)myView {
if (!_myView) {
_myView = [UIView new];
}
return _myView;
}
When you have declared a property like this:
@property(nonatomic, strong) UIView *myView;
You just change the OC Property Getter Body
code template of AppCode to:
if (!$IVAR) {
#if ($RETURN_TYPE.endsWith("*"))
#set($VAR_CLASS = $RETURN_TYPE.substring(0, $RETURN_TYPE.lastIndexOf("*")).trim())
#else
#set($VAR_CLASS = $RETURN_TYPE)
#end
$IVAR = [$VAR_CLASS new];
}
return $IVAR;
This solution was given to my by Dmitry Semeniouta from Jetbrains after I asked the question on their issue tracker: http://youtrack.jetbrains.com/issue/OC-9126
It's not meant as a 'Live Template' but a 'Code Template' so you should not need to add
$
and edit variables. Open Preferences->File and Code Templates->Code->OC Property Getter Body.