Skip to content

Instantly share code, notes, and snippets.

@ciryon
Created July 11, 2011 12:55
Show Gist options
  • Save ciryon/1075774 to your computer and use it in GitHub Desktop.
Save ciryon/1075774 to your computer and use it in GitHub Desktop.
MHHistory
// 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