Created
September 22, 2012 03:52
-
-
Save veritech/3765057 to your computer and use it in GitHub Desktop.
Lazy properties - Post ARC
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(){ | |
| NSObject *_foo; | |
| } | |
| @end | |
| //Implementation | |
| @implementation foo | |
| @dynamic 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