AppCode can generate getter code like this:
- (UIView *)leftAnchorView {
return _leftAnchorView;
}
In the Preferences -> Editor -> File and Code Templates -> Code Tab, I found the getter templates is
#if ($IVAR_IS_AVAILABLE == "true")
return $IVAR;#else
return $DEFAULT_RETURN_VALUE;#end
So,I modify the templates like this:
#if ($IVAR_IS_AVAILABLE == "true")
if(!$IVAR){
$CUSTOM_CODE
}
return $IVAR;#else
return $DEFAULT_RETURN_VALUE;#end
The result is
- (UIView *)leftAnchorView {
if(!_leftAnchorView){
}
return _leftAnchorView;
}
Now, my target is
- (UIView *)leftAnchorView {
if(!_leftAnchorView){
_leftAnchorView = [UIView new];
}
return _leftAnchorView;
}
Can anyone tell my how modify the code templates to achive my target? Thanks!