Commit 9f7e73cc authored by Felix Paul Kühne's avatar Felix Paul Kühne

MLAlbum: add ability to remove individual tracks from the set

parent 67722744
......@@ -23,6 +23,8 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
@class MLAlbumTrack;
@interface MLAlbum : NSManagedObject
+ (NSArray *)allAlbums;
......@@ -33,6 +35,9 @@
@property (nonatomic, retain) NSSet *tracks;
@property (nonatomic, retain, readonly) NSSet *unreadTracks;
- (void)removeTrack:(MLAlbumTrack *)track;
- (void)removeTrackWithNumber:(NSNumber *)trackNumber;
@end
......
......@@ -5,6 +5,8 @@ Next Version
Added Public APIs:
- MLShow:
- new selectors: removeEpisode, removeEpisodeWithSeasonNumberandEpisodeNumber
- MLAlbum:
- new selectors: removeTrack, removeTrackWithTrackNumber
Version 2.1.2
-------------
......
......@@ -24,6 +24,7 @@
*****************************************************************************/
#import "MLAlbum.h"
#import "MLAlbumTrack.h"
#import "MLMediaLibrary.h"
@implementation MLAlbum
......@@ -64,4 +65,40 @@
@dynamic tracks;
@dynamic unreadTracks;
- (void)removeTrack:(MLAlbumTrack *)track
{
if (!track)
return;
NSMutableSet *tracks = [self mutableSetValueForKey:@"tracks"];
[tracks removeObject:track];
[self willChangeValueForKey:@"tracks"];
[self setValue:tracks forKey:@"tracks"];
[self didChangeValueForKey:@"tracks"];
}
- (void)removeTrackWithNumber:(NSNumber *)trackNumber
{
NSMutableSet *tracks = [self mutableSetValueForKey:@"episodes"];
MLAlbumTrack *track = nil;
if (trackNumber) {
for (MLAlbumTrack *trackIter in tracks) {
if ([trackIter.trackNumber intValue] == [trackNumber intValue]) {
track = trackIter;
break;
}
}
}
if (!track)
return;
[tracks removeObject:track];
[self willChangeValueForKey:@"tracks"];
[self setValue:tracks forKey:@"tracks"];
[self didChangeValueForKey:@"tracks"];
}
@end
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