Skip to content

Instantly share code, notes, and snippets.

@jerryhjones
Created November 15, 2012 18:51
Show Gist options
  • Save jerryhjones/4080429 to your computer and use it in GitHub Desktop.
Save jerryhjones/4080429 to your computer and use it in GitHub Desktop.
@property (nonatomic, weak) UIView *someViewA;
@property (nonatomic, weak) UIView *someViewB;
- (void)someMethod
{
NSLog(@"view: %@", self.someViewA); // Prints a nil value
NSLog(@"view: %@", self.someViewB); // Prints the view
}
- (UIView *)someViewA
{
if (nil == _someViewA) {
_someViewA = [[UIView alloc] init];
}
return _someViewA;
}
- (UIView *)someView
{
UIView *view = nil;
if (nil == _someViewB) {
view = [[UIView alloc] init];
_someViewB = view
}
return _someViewB;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment