Skip to content

Instantly share code, notes, and snippets.


Nick Toumpelis nicktoumpelis

View GitHub Profile

Keybase proof

I hereby claim:

  • I am nicktoumpelis on github.
  • I am nicktoumpelis ( on keybase.
  • I have a public key ASDhV8XEW3HX-lbFiCZUO5E5CqW53I0Vp0WCdnpYwlr-Dwo

To claim this, I am signing this object:

View .gitignore
nicktoumpelis / SomeImplementation.m
Created Aug 31, 2014
Core Data: Use a stored fetch request
View SomeImplementation.m
NSManagedObjectModel *managedObjectModel = ...;
NSFetchRequest *fetchRequest = [managedObjectModel fetchRequestTemplateForName:@"Fetch Request Name"];
nicktoumpelis / SomeImplementation.m
Last active Aug 29, 2015
Core Data: Create a simple NSFetchRequest
View SomeImplementation.m
NSManagedObjectContext *managedObjectContext = ...;
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setEntity:[NSEntityDescription entityForName:@"Entity" inManagedObjectContext:managedObjectContext]];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"..."];
[fetchRequest setPredicate:predicate];
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"key" ascending:YES];
[fetchRequest setSortDescriptors:@[sortDescriptor]];
nicktoumpelis / SomeImplementation.m
Created Aug 31, 2014
Core Data: Execute a fetch request
View SomeImplementation.m
NSManagedObjectContext *managedObjectContext = ...;
NSFetchRequest *fetchRequest = ...;
NSError *error = nil;
NSArray *results = [managedObjectContext executeFetchRequest:request error:&error];
if (error) {
NSLog(@"Error: %@\n%@", [error localizedDescription], [error userInfo]);
nicktoumpelis / NATAppDelegate.m
Created Aug 27, 2014
Initialize Core Data stack
View NATAppDelegate.m
- (void)initializeCoreDataStack
// Some error checking is necessary...
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"ProjectName" withExtension:@"momd"];
NSManagedObjectModel *managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
NSPersistentStoreCoordinator *persistentStoreCoordinator =
[[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:managedObjectModel];
View AAAKlass.h
// external constants (defined in AAAKlass.m)
extern const CGFloat AAKlassVerticalMargin;
extern NSString * const AAAKlassIdentifier;
View KlassSpec.m
#import "Kiwi.h"
static NSTimeInterval const kAsynchronousTestingTimeout = 2.0;
describe(@"An object", ^{
context(@"when...", ^{
__block Klass *object = nil;
beforeAll(^{ // or 'beforeEach', depending on your needs
nicktoumpelis / Class.m
Created Aug 13, 2014
KVO observation done right
View Class.m
static void * const kKVOContext = (void *)&kKVOContext;
@implementation Class
- (void)someMethod {
[super someMethod];
[observedObject addObserver:self
nicktoumpelis /
Created Apr 23, 2014
Cleans and resets a git repo and its submodules
git clean -xfd
git submodule foreach --recursive git clean -xfd
git reset --hard
git submodule foreach --recursive git reset --hard
git submodule update --init --recursive