Properly set folder/notes property of new media
This commit is contained in:
parent
333ab0dace
commit
81dbe391d5
|
@ -52,17 +52,31 @@
|
||||||
return YES;
|
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 -
|
||||||
#pragma mark Media management
|
#pragma mark Media management
|
||||||
|
|
||||||
- (void)addMediaURL:(NSURL *)url name:(NSString *)name date:(NSDate *)date copying:(BOOL)copying
|
- (void)addMediaURL:(NSURL *)url name:(NSString *)name date:(NSDate *)date copying:(BOOL)copying
|
||||||
{
|
{
|
||||||
NSManagedObjectContext *moc = [self managedObjectContext];
|
NSManagedObjectContext *moc = [self managedObjectContext];
|
||||||
|
MAFolder *inbox = [self inboxFolder];
|
||||||
MAMedia * media = [NSEntityDescription insertNewObjectForEntityForName:@"MAMedia" inManagedObjectContext:moc];
|
MAMedia * media = [NSEntityDescription insertNewObjectForEntityForName:@"MAMedia" inManagedObjectContext:moc];
|
||||||
NSString * path = [url path];
|
NSString * path = [url path];
|
||||||
media.media = path;
|
media.media = path;
|
||||||
media.date = [date timeIntervalSince1970];
|
media.date = [date timeIntervalSince1970];
|
||||||
media.name = name;
|
media.name = name;
|
||||||
|
media.notes = @"";
|
||||||
|
media.folder= inbox;
|
||||||
[moc processPendingChanges];
|
[moc processPendingChanges];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user