Commit a726c3e3 authored by Felix Paul Kühne's avatar Felix Paul Kühne

MLShow: add selector to fetch a list of episodes sorted by season and episode number

parent aad52e7e
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
@property (nonatomic, retain) NSString *releaseYear; @property (nonatomic, retain) NSString *releaseYear;
@property (nonatomic, retain) NSNumber *lastSyncDate; @property (nonatomic, retain) NSNumber *lastSyncDate;
@property (nonatomic, retain) NSSet *episodes; @property (nonatomic, retain) NSSet *episodes;
@property (nonatomic, readonly) NSArray *sortedEpisodes;
@property (nonatomic, retain, readonly) NSSet *unreadEpisodes; @property (nonatomic, retain, readonly) NSSet *unreadEpisodes;
- (void)removeEpisode:(MLShowEpisode*)episode; - (void)removeEpisode:(MLShowEpisode*)episode;
......
...@@ -8,9 +8,10 @@ Next Version ...@@ -8,9 +8,10 @@ Next Version
Added Public APIs: Added Public APIs:
- MLShow: - MLShow:
- new selectors: removeEpisode, removeEpisodeWithSeasonNumberandEpisodeNumber - new selectors: removeEpisode, removeEpisodeWithSeasonNumberandEpisodeNumber,
sortedEpisodes
- MLAlbum: - MLAlbum:
- new selectors: removeTrack, removeTrackWithTrackNumber - new selectors: removeTrack, removeTrackWithTrackNumber, sortedTracks
- MLLabel - MLLabel
- new selector: allLabels - new selector: allLabels
......
...@@ -87,6 +87,22 @@ ...@@ -87,6 +87,22 @@
// return set; // return set;
//} //}
- (NSArray *)sortedEpisodes
{
NSArray *episodes = [[self valueForKey:@"episodes"] allObjects];
NSSortDescriptor *seasonDescriptor =
[[NSSortDescriptor alloc] initWithKey:@"seasonNumber"
ascending:YES
selector:@selector(compare:)];
NSSortDescriptor *episodesDescriptor =
[[NSSortDescriptor alloc] initWithKey:@"episodeNumber"
ascending:YES
selector:@selector(compare:)];
NSArray *descriptors = [NSArray arrayWithObjects:seasonDescriptor, episodesDescriptor, nil];
return [[episodes sortedArrayUsingDescriptors:descriptors] retain];
}
- (void)removeEpisode:(MLShowEpisode*)episode - (void)removeEpisode:(MLShowEpisode*)episode
{ {
if (!episode) if (!episode)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment