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 JRObject : NSObject @end | |
@implementation JRObject | |
- (void)doesNotRecognizeSelector:(SEL)selector { | |
NSLog(@"Attempted to invoke %s on %@", selector, self); | |
} | |
@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
@interface NSArray (JRAdditions) | |
- (id) safeObjectAtIndex:(NSUInteger)index; | |
@end | |
@implementation NSArray (JRAdditions) | |
- (id) safeObjectAtIndex:(NSUInteger)index { | |
@synchronized(self) { |
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
@implementation NSIndexPath (JRAdditions) | |
- (NSIndexPath *) indexPathByAddingRows:(NSInteger)rows andSections:(NSInteger)sections { | |
NSIndexPath *newIndexPath = [NSIndexPath indexPathForRow:MIN(NSIntegerMax, [self row] + rows) | |
inSection:MIN(NSIntegerMax, [self section] + sections)]; | |
return newIndexPath; | |
} | |
- (NSIndexPath *) indexPathByAddingRows:(NSInteger) rows { | |
return [self indexPathByAddingRows:rows andSections:0]; |
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
//GCD way: | |
double delayInSeconds = (24 * 60) * 60; | |
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC); | |
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ | |
[self setAge:[self age] + 1]; | |
}); | |
//NSInvocation way: |
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 UIView (JRHierarchyAdditions) | |
- (void)bringToFront; | |
- (void)sendToBack; | |
@end | |
@implementation UIView (JRHierarchyAdditions) | |
- (void)bringToFront { | |
[[self superview] bringSubviewToFront:self]; | |
} |
NewerOlder