Skip to content

Instantly share code, notes, and snippets.

View akitchen's full-sized avatar

Andrew Kitchen akitchen

View GitHub Profile
@akitchen
akitchen / AKPropertyValueForDate.m
Created November 20, 2012 04:08
An NSFetchRequest example for correlating two or more values instead of the array of NSManagedObjects it would otherwise give you
NSExpressionDescription *dateDescription = [[NSExpressionDescription alloc] init];
[dateDescription setName:@"date"];
[dateDescription setExpression:[NSExpression expressionForKeyPath:@"someKeyPath.date"]];
[dateDescription setExpressionResultType:NSDateAttributeType];
NSPropertyDescription *propertyDescription = [[fetchRequest.entity propertiesByName] objectForKey:@"propertyName"];
[fetchRequest setResultType:NSDictionaryResultType];
[fetchRequest setPropertiesToFetch:@[dateDescription, propertyDescription]];