Created
July 11, 2011 12:55
-
-
Save ciryon/1075774 to your computer and use it in GitHub Desktop.
MHHistory
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
// interface file | |
@interface MHHistory : NSObject | |
{ | |
NSMutableArray *_historyArray; | |
} | |
@property (nonatomic, retain) NSMutableArray *historyArray; | |
@end | |
+(MHHistory*)sharedTrackHistory; | |
-(void)addTrack:(MHTrack*)track; | |
-(NSUInteger)numberOfTracksInHistory; | |
-(MHTrack*)trackAtLocation:(NSUInteger)location; | |
// implementation file | |
@implementation MHistory; | |
@synthesize historyArray = _historyArray | |
static MHHistory* _staticHistory; | |
+(MHHistory*)sharedTrackHistory; | |
{ | |
if (_staticHistory==nil) { | |
_staticHistory = [[MHHistory alloc] init]; | |
} | |
return _staticHistory; | |
} | |
- (id)init | |
{ | |
if((self = [super init])) | |
{ | |
self.historyArray = [[NSMutableArray alloc] init]; | |
} | |
return self; | |
} | |
-(void)addTrack:(MHTrack*)track; | |
{ | |
[self.historyArray addObject:track]; | |
} | |
-(NSUInteger)numberOfTracksInHistory; | |
{ | |
return [self.historyArray count]; | |
} | |
-(MHTrack*)trackAtLocation:(NSUInteger)location; | |
{ | |
if (location < [self numberOfTracksInHistory] ) | |
{ | |
return [self.historyArray objectAtIndex:location]; | |
} | |
else { | |
return nil; | |
} | |
} | |
-(MHTrack*)lastTrack; | |
{ | |
return [self.historyArray lastObject]; | |
} | |
-(NSArray*)allTracks; | |
{ | |
return self.historyArray; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment