Skip to content

Instantly share code, notes, and snippets.

@cruffenach
Created July 13, 2011 17:31
Show Gist options
  • Save cruffenach/1080815 to your computer and use it in GitHub Desktop.
Save cruffenach/1080815 to your computer and use it in GitHub Desktop.
BlogPost with Synthesized Properties
#import <Foundation/Foundation.h>
@class Author;
@interface BlogPost : NSObject {
NSString *_postName;
NSDate *_postDate;
Author *_author;
}
@property (nonatomic, retain) NSString *postName;
@property (nonatomic, retain) NSDate *postDate;
@property (nonatomic, retain) Author *author;
@end
#import "BlogPost.h"
#import "Author.h"
@implementation BlogPost
@synthesize postName = _postName;
@synthesize postDate = _postDate;
@synthesize author = _author;
-(id)init {
if(self = [super init]) {
self.postName = @"";
self.postDate = [NSDate date];
self.author = nil;
}
return self;
}
-(void)dealloc {
[_postName release];
[_postDate release];
[_author release];
[super dealloc];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment