Created
September 22, 2012 04:57
-
-
Save veritech/3765174 to your computer and use it in GitHub Desktop.
Lazy properties - Solution 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Public interface | |
| @interface foo:NSObject | |
| @property (nonatomic,readonly) NSObject *bar; | |
| @end | |
| //Class Extension | |
| @interface foo() | |
| @property (nonatomic,readwrite,strong) NSObject *bar; | |
| @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