Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save veritech/3765074 to your computer and use it in GitHub Desktop.
Lazy properties - Latest solution
//Public interface
@interface foo:NSObject
@property (nonatomic,readonly) NSObject *bar;
@end
//Class Extension
@interface foo(){
NSObject *_foo;
}
@end
//Implementation
@implementation foo
- (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