Skip to content

Instantly share code, notes, and snippets.

@veritech
Created September 22, 2012 05:01
Show Gist options
  • Select an option

  • Save veritech/3765180 to your computer and use it in GitHub Desktop.

Select an option

Save veritech/3765180 to your computer and use it in GitHub Desktop.
Lazy properties - Solution 2
//Public interface
@interface foo:NSObject
@property (nonatomic,readonly) NSObject *bar;
@end
//Implementation
@implementation foo
@synthesize bar = _bar;
- (NSObject *)bar {
if (!_bar) {
_bar = [[NSObject alloc] init];
}
return _bar;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment