Skip to content

Instantly share code, notes, and snippets.

View tonyarnold's full-sized avatar

Tony Arnold tonyarnold

View GitHub Profile
@tonyarnold
tonyarnold / gist:6247976
Created August 16, 2013 07:29
Whhhhaaaaat…?!
(lldb) po primaryKeyName
userID
(lldb) po [destinationEntityAttributes valueForKey:primaryKeyName]
nil
(lldb) po [destinationEntityAttributes valueForKey:@"userID"]
(<NSAttributeDescription: 0x610000114d00>), name userID, isOptional 0, isTransient 0, entity User, renamingIdentifier userID, validation predicates (
"SELF >= 0"
), warnings (
1620
), versionHashModifier (null)
@tonyarnold
tonyarnold / then.m
Created August 15, 2013 14:50
I'm trying to work out why the `loginResult` signal never does anything. I've basically copied and updated the GHAPIDemo code that does the same thing.
self.currentlyLoggingIn = NO;
self.didLoginSubject = [RACSubject subject];
self.loginCommand = [RACCommand commandWithCanExecuteSignal:[RACSignal
combineLatest:@[self.usernameTextField.rac_textSignal,
self.passwordTextField.rac_textSignal,
RACObserve(self, currentlyLoggingIn)]
reduce:^(NSString *username, NSString *password, NSNumber *currentlyLoggingIn) {
return @(username.length > 0 && password.length > 0 && NO == currentlyLoggingIn.boolValue );
}]];
@tonyarnold
tonyarnold / libextobjc.podspec
Created August 8, 2013 03:42
Podspec for libextobjc HEAD
Pod::Spec.new do |s|
s.name = "libextobjc"
s.version = "0.3a"
s.summary = "A Cocoa library to extend the Objective-C programming language."
s.homepage = "https://github.com/jspahrsummers/libextobjc"
s.author = { "Justin Spahr-Summers" => "[email protected]" }
s.source = { :git => "https://github.com/jspahrsummers/libextobjc.git", :tag => s.version.to_s }
s.requires_arc = true
# Provided as a convenience but not requiring all the subspecs because it would be redundant
@tonyarnold
tonyarnold / ReactiveCocoa.podspec
Last active December 20, 2015 01:59
ReactiveCocoa 2.0 needs to include it's own version of libextobjc specifically. Until ReactiveCocoa 2.0 is properly released, you'll need to specify `pod "ReactiveCocoa", :head` in your project's Podfile.
Pod::Spec.new do |s|
s.name = "ReactiveCocoa"
s.version = "2.0-development"
s.summary = "A framework for composing and transforming sequences of values."
s.homepage = "https://github.com/blog/1107-reactivecocoa-is-now-open-source"
s.author = { "Josh Abernathy" => "[email protected]" }
s.source = { :git => "https://github.com/ReactiveCocoa/ReactiveCocoa.git", :branch => "fishhook-off-device" }
s.license = 'Simplified BSD License'
s.description = "ReactiveCocoa offers:\n" \
"1. The ability to compose operations on future data.\n" \
@tonyarnold
tonyarnold / Mantle.podspec
Created July 22, 2013 12:20
Fixes issues with ReactiveCocoa 2.0 and including it's own version of libextobjc specifically.
Pod::Spec.new do |s|
s.name = "Mantle"
s.version = "1.2"
s.summary = "Model framework for Cocoa and Cocoa Touch."
s.homepage = "https://github.com/github/Mantle"
s.license = 'MIT'
s.author = { "GitHub" => "[email protected]" }
s.source = { :git => "https://github.com/github/Mantle.git", :tag => "1.2" }
@tonyarnold
tonyarnold / NSManagedObjectContext+MagicalRecord.m
Created July 7, 2013 04:37
First sweep at updating MagicalRecord to use the new `NSManagedObjectContext`, `NSPersistentStoreCoordinator` and `NSPersistentStore` setup as recommended by Apple in WWDC2013 session 211: "Core Data Performance: Optimization and Debugging" It should be compatible with MagicalRecord 2.1.0, but hasn't been thoroughly tested yet.
//
// NSManagedObjectContext+MagicalRecord.m
//
// Created by Saul Mora on 11/23/09.
// Copyright 2010 Magical Panda Software, LLC All rights reserved.
//
#import "CoreData+MagicalRecord.h"
#import <objc/runtime.h>
@tonyarnold
tonyarnold / RACSignal+DeliverOnMainThread.h
Last active December 17, 2015 15:29
Use this to simplify your signals that need to be delivered on the main thread
//
// RACSignal+DeliverOnMainThread.h
//
// Created by Tony Arnold on 3/05/13.
// Copyright (c) 2013 The CocoaBots. All rights reserved.
//
#import <ReactiveCocoa/ReactiveCocoa.h>
@interface RACSignal (DeliverOnMainThread)
@tonyarnold
tonyarnold / gist:5244165
Created March 26, 2013 09:34
Autolayout to expand to fill available space?
|-10-[imageView]-4-[textLabel]-(>=15)-[detailTextLabel]-|
@tonyarnold
tonyarnold / gist:4966314
Created February 16, 2013 10:03
ROFLCopter
ROFL:ROFL:ROFL:LOL:ROFL:ROFL:ROFL:ROFL
______ / \______
L / \
L O L====== \__
L \________________________|
H H
/==============/
@tonyarnold
tonyarnold / mr-save-patterns.md
Last active October 21, 2023 00:55
Common save patterns for use with MagicalRecord

Common Save Patterns

Standard background save

Assuming that you don't care which NSManagedObjectContext is used, and you just want to make some changes and save them in the background, use the following method. 90% of the time, this is what you'll want.

NSManagedObjectSubclass *myObject = [NSManagedObjectSubclass MR_findFirst];

[MagicalRecord saveWithBlock:^(NSManagedObjectContext *localContext) {