From c91c79b7a3481f3287ad9e0aaba8bbc10a49eff3 Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Fri, 15 Nov 2013 19:55:14 +0100 Subject: [PATCH] Added - (NSUInteger)addChapter:(MP42TextSample *)chapter to MP42Chapter. --- MP42/MP42ChapterTrack.h | 1 + MP42/MP42ChapterTrack.m | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/MP42/MP42ChapterTrack.h b/MP42/MP42ChapterTrack.h index 7cc4072..18065bf 100644 --- a/MP42/MP42ChapterTrack.h +++ b/MP42/MP42ChapterTrack.h @@ -18,6 +18,7 @@ - (instancetype)initWithSourceURL:(NSURL *)URL trackID:(NSInteger)trackID fileHandle:(MP42FileHandle)fileHandle; + (instancetype)chapterTrackFromFile:(NSURL *)URL; +- (NSUInteger)addChapter:(MP42TextSample *)chapter; - (NSUInteger)addChapter:(NSString *)title duration:(uint64_t)timestamp; - (NSUInteger)addChapter:(NSString *)title image:(MP42Image *)image duration:(uint64_t)timestamp; diff --git a/MP42/MP42ChapterTrack.m b/MP42/MP42ChapterTrack.m index 045fa02..c6584f4 100644 --- a/MP42/MP42ChapterTrack.m +++ b/MP42/MP42ChapterTrack.m @@ -100,20 +100,27 @@ return [[[MP42ChapterTrack alloc] initWithTextFile:URL] autorelease]; } +- (NSUInteger)addChapter:(MP42TextSample *)chapter +{ + _isEdited = YES; + _areChaptersEdited = YES; + + [chapters addObject:chapter]; + [chapters sortUsingSelector:@selector(compare:)]; + + return [chapters indexOfObject:chapter]; +} + - (NSUInteger)addChapter:(NSString *)title duration:(uint64_t)timestamp { MP42TextSample *newChapter = [[MP42TextSample alloc] init]; newChapter.title = title; newChapter.timestamp = timestamp; - _isEdited = YES; - _areChaptersEdited = YES; - - [chapters addObject:newChapter]; - [chapters sortUsingSelector:@selector(compare:)]; + NSUInteger idx = [self addChapter:newChapter]; [newChapter release]; - return [chapters indexOfObject:newChapter]; + return idx; } - (NSUInteger)addChapter:(NSString *)title image:(MP42Image *)image duration:(uint64_t)timestamp { @@ -122,14 +129,10 @@ newChapter.image = image; newChapter.timestamp = timestamp; - _isEdited = YES; - _areChaptersEdited = YES; - - [chapters addObject:newChapter]; - [chapters sortUsingSelector:@selector(compare:)]; + NSUInteger idx = [self addChapter:newChapter]; [newChapter release]; - return [chapters indexOfObject:newChapter]; + return idx; } - (NSUInteger)indexOfChapter:(MP42TextSample *)chapterSample {