Properly set folder/notes property of new media
This commit is contained in:
parent
333ab0dace
commit
81dbe391d5
|
@ -52,17 +52,31 @@
|
|||
return YES;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Folder management
|
||||
|
||||
- (MAFolder *)inboxFolder
|
||||
{
|
||||
NSManagedObjectContext *moc = [self managedObjectContext];
|
||||
NSFetchRequest * inbox = [NSFetchRequest fetchRequestWithEntityName:@"MAFolder"];
|
||||
[inbox setPredicate:[NSPredicate predicateWithFormat:@"name == 'Inbox' AND parent == NULL"]];
|
||||
return [[moc executeFetchRequest:inbox error:nil] objectAtIndex:0];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Media management
|
||||
|
||||
- (void)addMediaURL:(NSURL *)url name:(NSString *)name date:(NSDate *)date copying:(BOOL)copying
|
||||
{
|
||||
NSManagedObjectContext *moc = [self managedObjectContext];
|
||||
MAFolder *inbox = [self inboxFolder];
|
||||
MAMedia * media = [NSEntityDescription insertNewObjectForEntityForName:@"MAMedia" inManagedObjectContext:moc];
|
||||
NSString * path = [url path];
|
||||
media.media = path;
|
||||
media.date = [date timeIntervalSince1970];
|
||||
media.name = name;
|
||||
media.notes = @"";
|
||||
media.folder= inbox;
|
||||
[moc processPendingChanges];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user