Skip to content

Instantly share code, notes, and snippets.

View veritech's full-sized avatar

Jonathan Dalrymple veritech

View GitHub Profile
- (id)initWithEntityName:(NSString *)aName
predicate:(NSPredicate *)aPredicate
sortDescriptors:(NSArray *)sortDescriptors
managedObjectContext:(NSManagedObjectContext *)aMOC
FRCoreDataExportOperation *op = [[FRCoreDataExportOperation alloc] initWithEntityName:@"Destination" managedObjectContext:<MAIN CONTEXT>];
//[Optional] Set the name of the output file
[op setFileName:@"output.txt"];
//Set the entity formatter
[op setEntityFormatter:[[FRCSVEntityFormatter alloc] init]];
[<YOUR OPERATION QUEUE> addOperation:op];
@veritech
veritech / FMDatabaseQueue+async.mm
Created February 9, 2013 02:34
Category to add Async methods to the FMDatabaseQueue
//
// FMDatabaseQueue+async.h
//
// Created by Jonathan Dalrymple on 05/02/2013.
//
#import <FMDB/FMDatabaseQueue.h>
#import <objc/runtime.h>
const static char *propertyName = "FR_asyncQueueProperty";
@veritech
veritech / UIImage+render.m
Created October 18, 2012 21:59
UIImage + rendering blocks
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>
typedef void(^UIImageRenderBlock)(CGContextRef context);
@interface UIImage (render)
+(UIImage *)imageWithSize:(CGSize) canvasSize block:(UIImageRenderBlock) aBlock;
@end
@veritech
veritech / gist:3765180
Created September 22, 2012 05:01
Lazy properties - Solution 2
//Public interface
@interface foo:NSObject
@property (nonatomic,readonly) NSObject *bar;
@end
//Implementation
@implementation foo
@veritech
veritech / gist:3765174
Created September 22, 2012 04:57
Lazy properties - Solution 1
//Public interface
@interface foo:NSObject
@property (nonatomic,readonly) NSObject *bar;
@end
//Class Extension
@interface foo()
@veritech
veritech / gist:3765074
Created September 22, 2012 04:04
Lazy properties - Latest solution
//Public interface
@interface foo:NSObject
@property (nonatomic,readonly) NSObject *bar;
@end
//Class Extension
@interface foo(){
NSObject *_foo;
@veritech
veritech / gist:3765057
Created September 22, 2012 03:52
Lazy properties - Post ARC
//Public interface
@interface foo:NSObject
@property (nonatomic,readonly) NSObject *bar;
@end
//Class Extension
@interface foo(){
NSObject *_foo;
@veritech
veritech / gist:3765043
Created September 22, 2012 03:43
Lazy properties - The original
//Public Interface
@interface foo:NSObject{
NSObject *_bar;
}
@property (nonatomic,readonly) NSObject *bar;
@end
//Implementation
@veritech
veritech / gist:3752864
Created September 19, 2012 22:51
AFJSONRequestOperation
//We use the fantastic AF Networking
operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:[request preparedURLRequest]]
success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON){
//The JSON variable will contain the currently logged users information!
}
failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
//Handle any request errors
}];
//Ideally we would add this operation to a global operation queue