Skip to content

Instantly share code, notes, and snippets.

View RobvH's full-sized avatar
😅
Grateful

Rob van Hoose RobvH

😅
Grateful
View GitHub Profile
@RobvH
RobvH / gist:4010398
Created November 4, 2012 05:05
Core Data, using NSExpressions, how can we get these results to also include Department names?
- (void)fetchDepartmentExpenditureTotals
{
NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"Department"];
// get all departments
request.predicate = nil;
// perhaps a second fetch could get the names and sort the same way, but this feels kludgy
NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES];
request.sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
@RobvH
RobvH / Category+Transient.h
Created October 28, 2012 07:37
Core Data transient attributes - how to add needed custom code to category to preserve autogeneration of managed object sub class files
#import "Category.h"
@interface Category (Transient)
@property (nonatomic, strong) UIColor *color;
- (UIColor *)primitiveColor;
- (void)setPrimitiveColor:(UIColor *)value;
- (NSData *)primitiveColorData;
- (void)setPrimitiveColorData:(NSData *)value;