Created
July 30, 2012 04:08
-
-
Save hisasann/3204441 to your computer and use it in GitHub Desktop.
Objective-Cでシングルトン
This file contains 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
#import "Status.h" | |
@implementation Status | |
@synthesize customUrlAlbumId = _customUrlAlbumId; | |
@synthesize isTopReload = _isTopReload; | |
@synthesize isThumbnailReload = _isThumbnailReload; | |
@synthesize isInvitationReload = _isInvitationReload; | |
static Status *sharedHistory = nil; | |
+ (Status *)sharedManager { | |
@synchronized (self) { | |
if (sharedHistory == nil) { | |
sharedHistory = [[self alloc] init]; | |
} | |
} | |
return sharedHistory; | |
} | |
+ (id)allocWithZone:(NSZone *)zone { | |
@synchronized (self) { | |
if (sharedHistory == nil) { | |
sharedHistory = (Status *) [super allocWithZone:zone]; | |
return sharedHistory; | |
} | |
} | |
return nil; | |
} | |
- (id)copyWithZone:(NSZone *)zone { | |
return self; // シングルトン状態を保持するため何もせず self を返す | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment