Skip to content

Instantly share code, notes, and snippets.

//Pull all the policy option hash's into memory
NSManagedObjectContext *managedObjectContext = [[SalesManager sharedSalesManager] managedObjectContext];
NSExpressionDescription* objectIdDesc = [NSExpressionDescription new];
objectIdDesc.name = @"objectID";
objectIdDesc.expression = [NSExpression expressionForEvaluatedObject];
objectIdDesc.expressionResultType = NSObjectIDAttributeType;
NSFetchRequest *search = [NSFetchRequest fetchRequestWithEntityName:[ExtraPrice entityName]];
search.resultType = NSDictionaryResultType;
search.returnsDistinctResults = YES;
//
// Created by Liam Nichols on 06/08/2013.
// Copyright (c) 2013 Liam Nichols. All rights reserved.
//
// To change the template use AppCode | Preferences | File Templates.
//
#import "LNCollectionViewPagedLayout.h"
@liamnichols
liamnichols / UIColor+STColor.m
Created September 10, 2013 15:02
UIColor to UIImage
#pragma mark - UIImage Representations
- (UIImage *)imageRepresentation
{
CGFloat scale = [[UIScreen mainScreen] scale];
CGRect rect = CGRectMake(0, 0, scale, scale);
CGColorSpaceRef rgbColorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef context = CGBitmapContextCreate(NULL, CGRectGetWidth(rect), CGRectGetHeight(rect), 8, 0, rgbColorSpace, kCGImageAlphaPremultipliedFirst);
@liamnichols
liamnichols / gist:6413368
Created September 2, 2013 14:19
Renders all the sublayers of all the subviews within a specified view to file
static NSString *dir = @"/Users/liam.nichols/Desktop/layers/";
-(void)sublayersToFile
{
for (UIWindow *window in [[UIApplication sharedApplication] windows])
{
if ([window isKindOfClass:NSClassFromString(@"UITextEffectsWindow")])
{
[self subviewsInView:window];
break;
#pragma mark - Keyboard Appearance
- (void)keyboardWillShow:(NSNotification *)notification
{
NSDictionary* info = [notification userInfo];
CGRect keyboardFrame = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
keyboardFrame = [self.view.window convertRect:keyboardFrame toView:self.view];
CGRect intersectRect = CGRectIntersection(self.view.frame, keyboardFrame);