Skip to content

Instantly share code, notes, and snippets.

View onmyway133's full-sized avatar
😇
What you don't know is what you haven't learned

Khoa onmyway133

😇
What you don't know is what you haven't learned
View GitHub Profile
@onmyway133
onmyway133 / NS_ENUM
Last active August 29, 2015 13:58
NS_ENUM
typedef NS_ENUM(NSInteger, UITableViewCellStyle) {
UITableViewCellStyleDefault,
UITableViewCellStyleValue1,
UITableViewCellStyleValue2,
UITableViewCellStyleSubtitle
};
@onmyway133
onmyway133 / View Controller Containment
Last active May 15, 2016 11:55
View Controller Containment
// Adding A Child View Controller
[self addChildViewController:viewController];
viewController.view.frame = self.view.bounds;
[self.view addSubview:viewController.view];
[viewController didMoveToParentViewController:self];
// Removing A Child From A Parent
[viewController willMoveToParentViewController:nil];
[viewController.view removeFromSuperview];
[viewController removeFromParentViewController];
@onmyway133
onmyway133 / NSKeyedArchiver
Last active August 29, 2015 13:58
NSKeyedArchiver
Get document directory
NSString *documentDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
NSString *filePath = [documentDir stringByAppendingPathComponent:@"file.bin"];
Save
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:object];
[NSKeyedArchiver archiveRootObject:data toFile:filePath];
Load
NSData *data = [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
@onmyway133
onmyway133 / Suppress Xcode warning
Last active August 29, 2015 14:02
Suppress Xcode warning
Deprecated declarations
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
NSLog(@"Your code goes here");
#pragma clang diagnostic pop
PerformSelector
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[self.ticketTarget performSelector: self.ticketAction withObject: self];
@onmyway133
onmyway133 / Xcode Select
Last active August 29, 2015 14:03
Xcode Select
// Xcode 6 Beta to use Swift REPL
sudo xcode-select -switch /Applications/Xcode6-Beta.app/Contents/Developer
xcrun swift
lldb --repl
// Xcode 5
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
@onmyway133
onmyway133 / Adding Sublime Text 2 to command line
Last active August 29, 2015 14:03
Adding Sublime Text 2 to command line
sudo ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /bin/subl
@onmyway133
onmyway133 / Install homebrew
Last active August 29, 2015 14:03
Install homebrew
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"
@onmyway133
onmyway133 / Install MacPort
Last active August 29, 2015 14:03
Install MacPort
Download for Mavericks https://guide.macports.org/chunked/installing.macports.html
Edit ~/.zshrc
export PATH="/opt/local/bin:/usr/local/bin:$PATH"
@onmyway133
onmyway133 / Install pip
Last active August 18, 2021 20:11
Install pip
sudo easy_install pip
@onmyway133
onmyway133 / Install macvim
Last active August 29, 2015 14:03
Install macvim
brew install macvim --env-std --override-system-vim
brew linkapps
Usage
mvim