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)someSetupMethod { | |
[[NSNotificationCenter defaultCenter] addObserver:self | |
selector:@selector(keyboardWillShow:) | |
name:UIKeyboardWillShowNotification object:nil]; | |
} | |
- (void)someTeardownMethod { | |
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification 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
NSMutableArray* reversedMessages = [NSMutableArray arrayWithCapacity:[messages count]]; | |
NSEnumerator* reverseEnumerator = [messages reverseObjectEnumerator]; | |
for (id object in reverseEnumerator) | |
{ | |
[reversedMessages addObject:Object]; | |
} | |
// http://stackoverflow.com/questions/7457944/reverse-a-nsarray-worry |
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
var Guest = Backbone.Model.extend(); | |
var Table = Backbone.Model.extend(); | |
var firstGuest = new Guest(guests[0]); | |
var GuestView = Backbone.View.extend({ | |
initialize: function () { | |
this.listenTo(this.model, 'change', this.render); | |
}, | |
tagName: 'h1', |
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
UIWebView *webView = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].bounds]; | |
webView.delegate = self; | |
webView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin; | |
NSURL *htmlPath = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"about" ofType:@"html"]isDirectory:NO]; | |
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0); | |
dispatch_async(queue, ^{ | |
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
+(id)singleton{ | |
static dispatch_once_t once; | |
static id singleton; | |
dispatch_once(&once, ^ { singleton = [[self alloc] init]; }); | |
return singleton; | |
} |
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)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender | |
{ | |
if ([[segue identifier] isEqualToString:@"showDetail"]) { | |
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; | |
NSManagedObject *object = [[self fetchedResultsController] objectAtIndexPath:indexPath]; | |
[[segue destinationViewController] setDetailItem:object]; | |
} | |
} |
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)bubbleSortArray:(NSMutableArray*)unsortedArray{ | |
while (TRUE) { | |
BOOL hasSwapped = NO; | |
for (int i=0; i<unsortedArray.count; i++){ | |
/** out of bounds check */ | |
if (i < unsortedArray.count-1){ |
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)setupBackButtonWithSelector:(SEL)selector { | |
// create a custom button | |
LIButton *backButton = [LIButton buttonWithType:UIButtonTypeCustom]; | |
backButton.positionInNavBar = LIButtonNavPositionLeft; | |
// more back button setup | |
// add back button to navigation bar | |
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:backButton]; | |
self.navigationItem.leftBarButtonItem = backItem; | |
} |
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
var h = require('virtual-dom/h'); | |
var str = require('virtual-dom-stringify'); | |
var http = require('http'); | |
var fs = require('fs'); | |
var ecstatic = require('ecstatic'); | |
var st = ecstatic(__dirname); | |
var server = http.createServer(function (req, res) { | |
if (req.url === '/') { | |
fs.readdir(__dirname + '/images', onfiles); |
OlderNewer