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

Rework unread property

parent 05fbaa9e
......@@ -174,26 +174,7 @@ NSString *kMLFileTypeAudio = @"audio";
@dynamic folderTrackNumber;
@dynamic genre;
@dynamic albumTrack;
- (NSNumber *)unread
{
[self willAccessValueForKey:@"unread"];
NSNumber *ret = [self primitiveValueForKey:@"unread"];
[self didAccessValueForKey:@"unread"];
return ret;
}
- (void)setUnread:(NSNumber *)unread
{
@try {
[self willChangeValueForKey:@"unread"];
[self setPrimitiveValue:unread forKey:@"unread"];
[self didChangeValueForKey:@"unread"];
}
@catch (NSException *exception) {
APLog(@"setUnread raised exception");
}
}
@dynamic unread;
- (NSNumber *)lastPosition
{
......
......@@ -69,23 +69,23 @@
@dynamic lastSyncDate;
@dynamic releaseYear;
@dynamic episodes;
@dynamic unreadEpisodes;
//- (NSSet *)unreadEpisodes
//{
// NSSet *episodes = [self episodes];
// NSMutableSet *set = [NSMutableSet set];
// for(id episode in set) {
// NSSet *files = [episode valueForKey:@"files"];
// for(id file in files) {
// if ([[file valueForKey:@"unread"] boolValue]) {
// [set addObject:episode];
// break;
// }
// }
// }
// return set;
//}
- (NSSet *)unreadEpisodes
{
NSArray *episodes = [[self valueForKey:@"episodes"] allObjects];
NSMutableSet *set = [NSMutableSet set];
NSUInteger count = episodes.count;
for (NSUInteger x = 0; x < count; x++) {
NSSet *files = [episodes[x] valueForKey:@"files"];
for (id file in files) {
if ([[file valueForKey:@"unread"] boolValue]) {
[set addObject:episodes[x]];
break;
}
}
}
return set;
}
- (NSArray *)sortedEpisodes
{
......
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