This file contains 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
// | |
// StyleUtil.m | |
#import "StyleUtil.h" | |
// Normally I'll import UIColor+Hex.h | |
// but for sake of the gist, I included the category inline | |
// #import "UIColor+Hex.h" |
This file contains 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
- (void)registerForKeyboardNotifications | |
{ | |
[[NSNotificationCenter defaultCenter] addObserver:self | |
selector:@selector(keyboardWillShow:) | |
name:UIKeyboardWillShowNotification object:nil]; | |
[[NSNotificationCenter defaultCenter] addObserver:self | |
selector:@selector(keyboardWillHide:) | |
name:UIKeyboardWillHideNotification object:nil]; |
This file contains 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 AutoLayoutLabel : UILabel | |
@end | |
@implementation AutoLayoutLabel | |
{ | |
CGFloat overrideWidth; | |
} | |
- (id)init |
This file contains 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
#pragma mark - NSFastEnumeration | |
- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state | |
objects:(__unsafe_unretained id [])buffer count:(NSUInteger)len | |
{ | |
return [dictionary.allValues countByEnumeratingWithState:state objects:stackbuf count:len]; | |
} | |
#pragma mark - |
This file contains 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
likes(bear, honey). | |
likes(human, honey). | |
likes(racoon, chicken). | |
likes(pig, slop). | |
likes(vulture,roadkill). | |
flavor(sweet, honey). | |
flavor(savory, chicken). | |
flavor(gross, slop). | |
flavor(gross,roadkill). |
This file contains 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
// getting this error? | |
// "An observer of NSManagedObjectContextDidSaveNotification illegally threw an exception" | |
// observing the notification here | |
[[NSNotificationCenter defaultCenter] addObserver:self | |
selector:@selector(otherContextDidSave:) | |
name:NSManagedObjectContextDidSaveNotification object:nil]; | |
// FIX: you must mergeChangesFromContextDidSaveNotification: on main thread |