Skip to content

Instantly share code, notes, and snippets.

@whalec
Created August 22, 2010 06:18
Show Gist options
  • Save whalec/543413 to your computer and use it in GitHub Desktop.
Save whalec/543413 to your computer and use it in GitHub Desktop.
# AViewController.h
@interface AViewController : UIViewController
{
}
@property(readwrite, retain) NSString *aString;
@property(readwrite, assign, getter=isReady) BOOL ready;
# AViewController.m
@implementation AViewController
@synthesize aString = _aString;
- (void)viewDidLoad
{
# By doing this you avoid many of the headaches and pitfalls of
# managing memory.
self.aString = @"A string that is now retained";
self.ready = NO;
}
- (void)someAction
{
if (self.isReady)
NSLog(self.aString);
}
- (void)dealloc
{
self.aString = nil, [_aString release];
[super dealloc];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment