MLLabel.m 1.91 KB
Newer Older
1 2 3 4 5 6 7 8 9
/*****************************************************************************
 * MLLabel.m
 * Lunettes
 *****************************************************************************
 * Copyright (C) 2010 Pierre d'Herbemont
 * Copyright (C) 2010-2013 VLC authors and VideoLAN
 * $Id$
 *
 * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
10
 *          Felix Paul Kühne <fkuehne # videolan.org>
11
 *
12 13 14
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
15 16 17 18
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
21
 *
22 23 24
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25
 *****************************************************************************/
Pierre's avatar
Pierre committed
26

Pierre's avatar
Pierre committed
27
#import "MLLabel.h"
28
#import "MLMediaLibrary.h"
Pierre's avatar
Pierre committed
29
#import "MLFile.h"
Pierre's avatar
Pierre committed
30

Pierre's avatar
Pierre committed
31
@implementation MLLabel
Pierre's avatar
Pierre committed
32

33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
+ (NSArray *)allLabels
{
    NSFetchRequest *request = [[NSFetchRequest alloc] init];
    NSManagedObjectContext *moc = [[MLMediaLibrary sharedMediaLibrary] managedObjectContext];
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Label" inManagedObjectContext:moc];
    [request setEntity:entity];

    NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:NO];
    [request setSortDescriptors:@[descriptor]];

    NSArray *labels = [moc executeFetchRequest:request error:nil];
    [request release];
    [descriptor release];

    return labels;
}

Pierre's avatar
Pierre committed
50 51 52 53
@dynamic name;
@dynamic files;

@end