Commit 20d2c6f4 authored by Felix Paul Kühne's avatar Felix Paul Kühne

MLFile: add convenience selector to get a MLFile object for any URL

parent 14bc372d
......@@ -37,6 +37,7 @@ extern NSString *kMLFileTypeAudio;
@interface MLFile : NSManagedObject
+ (NSArray *)allFiles;
+ (NSArray *)fileForURL:(NSString *)url;
- (BOOL)isKindOfType:(NSString *)type;
- (BOOL)isMovie;
......
Version 2.3
-----------
Added Public APIs:
- MLFile:
- new selector: fileForURL
Version 2.2.1
-------------
- FIX: incorrect return value for untitled TV shows
......
......@@ -66,6 +66,27 @@ NSString *kMLFileTypeAudio = @"audio";
return movies;
}
+ (NSArray *)fileForURL:(NSString *)url;
{
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSManagedObjectContext *moc = [[MLMediaLibrary sharedMediaLibrary] managedObjectContext];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"File" inManagedObjectContext:moc];
[request setEntity:entity];
[request setPredicate:[NSPredicate predicateWithFormat:@"url == %@", url]];
NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"title" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
[request setSortDescriptors:@[descriptor]];
NSError *error;
NSArray *files = [moc executeFetchRequest:request error:&error];
[request release];
[descriptor release];
if (!files)
APLog(@"WARNING: %@", error);
return files;
}
- (BOOL)isKindOfType:(NSString *)type
{
return [self.type isEqualToString:type];
......
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