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
// 1 - nice example from the iPhone for dummies book. Thanks Neal Goldstein! this should be boilerplate reachability | |
// put in the ApplicationDidFinishLaunchingWithOptions:launchOptions: | |
// import reachability + make sure that ARC is turned of through -fno-objc-arc | |
// also import the System configuration framework | |
// and inside the Reachability class > | |
// #import <netinet/in.h> | |
NetworkStatus networkStatus = [[Reachability reachabilityForInternetConnection] currentReachabilityStatus]; | |
if(networkStatus == NotReachable) { |
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
CGPoint center = CGPointMake(_car.center.x, self.view.frame.origin.y + _car.frame.size.height/2); | |
[UIView animateWithDuration:3 animations:^{ | |
_car.center =center; | |
} | |
completion:^(BOOL finished) { | |
[self rotate]; | |
} | |
]; |
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)viewDidLoad | |
{ | |
// gesture recognize | |
UISwipeGestureRecognizer *swipeGesture = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeGesture:)]; | |
swipeGesture.direction = UISwipeGestureRecognizerDirectionLeft; | |
[self.view addGestureRecognizer:swipeGesture]; | |
} |
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
// simple demo of a block | |
// create a new NSString variable demo storing the value hello | |
NSString *demo = @"Hello"; | |
// define a block with function name helloBlock | |
void(^helloBlock)(NSString*) = ^(NSString *param) { | |
NSLog(@"%@,%@", demo, param); | |
}; |
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
// http://stackoverflow.com/questions/9450391/show-screen-on-first-launch-only-in-ios | |
if (![@"1" isEqualToString:[[NSUserDefaults standardUserDefaults] | |
objectForKey:@"Avalue"]]) { | |
[[NSUserDefaults standardUserDefaults] setValue:@"1" forKey:@"Avalue"]; | |
[[NSUserDefaults standardUserDefaults] synchronize]; | |
//Action here |
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
// source: http://stackoverflow.com/questions/12395200/how-to-develop-or-migrate-apps-for-iphone-5-screen-resolution/12397309#12397309 | |
CGRect screenBounds = [[UIScreen mainScreen] bounds]; | |
if (screenBounds.size.height == 568) { | |
// code for 4-inch screen | |
} else { | |
// code for 3.5-inch screen | |
} |
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
-(IBAction)homeBtn:(id)sender | |
{ | |
NSLog(@"Action Button Pressed"); | |
[self.view removeFromSuperview]; | |
UIStoryboard *settingsStoryboard = [UIStoryboard storyboardWithName:@"BentoRock" bundle:nil]; | |
UIViewController *initialSettingsVC = [settingsStoryboard instantiateInitialViewController]; | |
// i'm going to load this view controller modally | |
initialSettingsVC.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal; | |
[self presentViewController:initialSettingsVC | |
animated:YES |
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 |
OlderNewer