Skip to content

Instantly share code, notes, and snippets.

View hlxwell's full-sized avatar
⛷️
Focusing

Michael He hlxwell

⛷️
Focusing
View GitHub Profile
@hlxwell
hlxwell / new_gist_file
Created April 10, 2013 01:34
Number is even or not
number % 2
@hlxwell
hlxwell / new_gist_file
Created April 10, 2013 02:17
transition from view to view
[self transitionFromViewController: toViewController: duration: options: animations: completion];
self.view.transform = xxx
@hlxwell
hlxwell / new_gist_file
Created April 10, 2013 06:45
Good service for making image placeholder
http://placehold.it/120x100
@hlxwell
hlxwell / new_gist_file
Created April 16, 2013 02:53
Animate from one view to another
[UIView transitionFromView:self.view toView:listsViewController.view
duration:1 options:UIViewAnimationOptionTransitionFlipFromRight
completion:^(BOOL finished) {
[[UIApplication sharedApplication].delegate window].rootViewController = listsViewController;
}];
@hlxwell
hlxwell / new_gist_file
Created April 17, 2013 05:12
Cleanup Icon Badge Number
- (void)applicationDidBecomeActive:(UIApplication *)application
{
application.applicationIconBadgeNumber = 0;
}
@hlxwell
hlxwell / new_gist_file
Created April 17, 2013 06:38
NSObject method for sending message to them.
NSObject
Sending Messages
– performSelector:withObject:afterDelay:
– performSelector:withObject:afterDelay:inModes:
– performSelectorOnMainThread:withObject:waitUntilDone:
– performSelectorOnMainThread:withObject:waitUntilDone:modes:
– performSelector:onThread:withObject:waitUntilDone:
– performSelector:onThread:withObject:waitUntilDone:modes:
– performSelectorInBackground:withObject:
+ cancelPreviousPerformRequestsWithTarget:
*.app
build/
.DS_Store
*~
.LSOverride
*.xcuserdatad
*.xcworkspace
@hlxwell
hlxwell / new_gist_file
Created April 19, 2013 05:13
Command lines to ignore xcuserstate file
git rm --cached ProjectFolder.xcodeproj/project.xcworkspace/xcuserdata/myUserName.xcuserdatad/UserInterfaceState.xcuserstate
git commit -m "Removed file that shouldn't be tracked"
@hlxwell
hlxwell / new_gist_file
Created April 23, 2013 05:58
Calculate the age
NSDate* now = [NSDate date];
NSDateComponents* ageComponents = [[NSCalendar currentCalendar]
components:NSYearCalendarUnit
fromDate:self.birthday
toDate:now
options:0];
NSInteger age = [ageComponents year];
@hlxwell
hlxwell / new_gist_file
Created May 2, 2013 02:54
Mutex in objective-c
@synchronized(self) {
// Code here will be execute by only one thread.
}