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
NSTimeInterval start = [[NSDate date] timeIntervalSince1970]; | |
// Code to execute. | |
NSTimeInterval finish = [[NSDate date] timeIntervalSince1970]; | |
NSLog(@"Execution took %f seconds.", finish - start); |
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
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
if (indexPath.row % 2 == 0) { | |
UIColor *altCellColor = [UIColor colorWithWhite:0.7 alpha:0.1]; | |
cell.backgroundColor = altCellColor; | |
} | |
} |
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
// Pause app and enter into debugger | |
// Any ambiguous layouts will be labeled | |
po [[UIWindow keyWindow] _autolayoutTrace] |
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
void ConditionalSwitchUsingNumber(int number); | |
int main(int argc, const char * argv[]) | |
{ | |
@autoreleasepool | |
{ | |
ConditionalSwitchUsingNumber(0); | |
ConditionalSwitchUsingNumber(1); | |
ConditionalSwitchUsingNumber(2); | |
ConditionalSwitchUsingNumber(6); |
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
# Works best when an Xcode project is already open. | |
# Full Terminal command: | |
cd `osascript -e "tell application \"Xcode\" to get project directory of front project"`; pwd; | |
# Optional: Add this as an alias to .bash_profile. Then type "xt" in Terminal to invoke the command. | |
alias xt='cd `osascript -e "tell application \"Xcode\" to get project directory of front project"`; pwd;' |
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
// | |
// NSString+Reversed.h | |
// | |
// Created by Bryan Luby on 5/16/13. | |
// | |
#import <Foundation/Foundation.h> | |
@interface NSString (Reversed) |
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
// http://stackoverflow.com/a/4242037/1306872 | |
- (void)inspectResponderChainFromSender:(id)sender | |
{ | |
if ([sender isKindOfClass:[UIResponder class]]) { | |
NSMutableArray *responderChain = [NSMutableArray array]; | |
[responderChain insertObject:sender atIndex:0]; | |
while ((sender = [sender nextResponder])) { | |
if ([sender nextResponder]) { |
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
// Make sure viewDidAppear has happened before sending this action to ensure that all links | |
// in the responder chain are connected. | |
// http://stackoverflow.com/a/11768282/1306872 | |
[[UIApplication sharedApplication] sendAction:@selector(resignFirstResponder) | |
to:nil | |
from:nil | |
forEvent:nil]; | |
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
- (void)handleKeyboardShow:(NSNotification *)notification | |
{ | |
NSDictionary *dict = notification.userInfo; | |
NSValue *rectValue = dict[UIKeyboardFrameEndUserInfoKey]; | |
CGRect keyboardRect = [rectValue CGRectValue]; | |
UITextView *activeTextView; | |
if ([self.textView1 isFirstResponder]) { | |
activeTextView = self.textView1; | |
} else if ([self.textView2 isFirstResponder]) { |
OlderNewer