Files
Drew McCormack 2991c71749 Reverted Idiomatic to only use plain text, instead of attributed text. The attributed text is not cross platform compatible.
Any existing copies of Idiomatic need to be removed, and any cloud data deleted.
2014-01-01 11:58:38 +01:00

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