This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface UITableViewCell (FixConstraints) | |
/* Finds any constraints that relate between a subview of the cell's content | |
* view and the cell itself, and replaces them with otherwise identical constraints | |
* that replace the cell with the content view. | |
* | |
* This works around a bug in Interface Builder where subviews added to a content | |
* view have their constraints related to the cell itself and not the content view, | |
* which can cause problems if you need to move the content view in any way (e.g. | |
* swipe to delete). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
On the basis that you are the intended recipient, then receipt of this email by you represents your confirmation that you agree, or continue to agree, to be bound by our standard Terms and Conditions applicable to the transaction to which this email relates. If you require a copy (or a replacement copy) of the applicable standard Terms and Conditions please email your request by return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I have an entity Foo, which has a 1-n relationship with Bar. Bar has a 1-n relationship with Baz. | |
On the main thread, the UI is showing a list of all the Bars in a single Foo. I am using KVO on Foo's bars relationship to detect when Bars are added to Foo. | |
Using a child MOC of the main MOC (the UI uses the main MOC), I create a new Bar, associate it with a couple of Baz objects, then add it to Foo's bars relationship. | |
Then I save the child MOC, which causes its changes to be merged into the main MOC. | |
At this point, my KVO observer on foo.bars fires, and when I inspect the change dictionary, I see my inserted Bar object however, the Bar's bazes relationship is empty! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSManagedObjectContext *contextOne = ...; | |
NSArray *objects = ...<result of fetch request on contextOne... | |
NSManagedObjectID *objectID = objects[0].objectID; | |
NSManagedObjectContext *contextTwo = ...; | |
id object = [contextTwo existingObjectWithID:objectID error:nil]; // returns the right object | |
NSAssert(![object.objectID isTemporaryID]); // passes | |
id otherObject = [contextTwo objectWithID:objectID]; // always returns an object, should be the right object | |
NSAssert(![otherObject.objectID isTemporaryID]); // fails! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EPISILON = 0.01 # calculate to the nearest cent | |
def calculate_balance_remaining_after_year(starting_balance, monthly_payment, annual_interest_rate) | |
12.times.reduce(starting_balance) do |balance| | |
balance -= monthly_payment | |
balance += (annual_interest_rate / 12) * balance | |
end | |
end | |
def calculate_lowest_payment_within_bounds(starting_balance, annual_interest_rate, lower_bound, upper_bound) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSLayoutConstraintBuilder *builder = [NSLayoutConstraintBuilder builder]; | |
UIView *mySubview = [[UIView alloc] initWithFrame:CGRectZero]; | |
// API deliberately mirrors the terminology of IB: | |
[builder pin:mySubview toWidth:200]; | |
[builder pin:mySubview toHeight:200]; | |
[builder pin:mySubview toSize:CGSizeMake(200, 200)]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Allows you to give a context a descriptive name to aid in | |
* debugging. | |
*/ | |
@interface NSManagedObjectContext (DescriptiveName) | |
@property (nonatomic, copy) NSString *descriptiveName; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSCalendar *utcCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSISO8601Calendar]; | |
[utcCalendar setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
State A (current): | |
branch foo: A -- B -- C -- D | |
\ | |
branch bar: -- E -- F -- G --H | |
I want commit E from bar brought back into foo, without cherry-picking and creating a new commit. Essentially I want to go to this: | |
State B: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Pod::Spec.new do |s| | |
s.name = 'LRMocky' | |
s.version = '1.0' | |
s.license = 'MIT' | |
s.summary = 'A mock object library for Objective C, inspired by JMock 2.0' | |
s.homepage = 'http://github.com/lukeredpath/LRMocky' | |
s.authors = { 'Luke Redpath' => '[email protected]' } | |
s.source = { :git => 'https://github.com/lukeredpath/LRMocky.git' } | |
s.requires_arc = true | |