mirror of
https://github.com/drewmccormack/ensembles.git
synced 2026-03-03 18:23:18 +01:00
43 lines
1.1 KiB
Objective-C
43 lines
1.1 KiB
Objective-C
//
|
|
// IDMNote.m
|
|
// Idiomatic
|
|
//
|
|
// Created by Drew McCormack on 20/09/13.
|
|
// Copyright (c) 2013 The Mental Faculty B.V. All rights reserved.
|
|
//
|
|
|
|
#import "IDMNote.h"
|
|
#import "IDMTag.h"
|
|
|
|
|
|
@implementation IDMNote
|
|
|
|
@dynamic text;
|
|
@dynamic creationDate;
|
|
@dynamic tags;
|
|
@dynamic uniqueIdentifier;
|
|
|
|
- (void)awakeFromInsert
|
|
{
|
|
[super awakeFromInsert];
|
|
self.uniqueIdentifier = [[NSProcessInfo processInfo] globallyUniqueString];
|
|
self.creationDate = [[NSDate alloc] init];
|
|
}
|
|
|
|
+ (NSArray *)notesInManagedObjectContext:(NSManagedObjectContext *)context
|
|
{
|
|
return [self notesWithTag:nil inManagedObjectContext:context];
|
|
}
|
|
|
|
+ (NSArray *)notesWithTag:(IDMTag*)tag inManagedObjectContext:(NSManagedObjectContext *)context
|
|
{
|
|
NSFetchRequest * fetchRequest = [[NSFetchRequest alloc] initWithEntityName:@"IDMNote"];
|
|
fetchRequest.predicate = tag ? [NSPredicate predicateWithFormat:@"%@ IN tags", tag] : nil;
|
|
fetchRequest.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"creationDate" ascending:NO]];
|
|
NSArray *notes = [context executeFetchRequest:fetchRequest error:nil];
|
|
return notes;
|
|
}
|
|
|
|
|
|
@end
|