Skip to content

Instantly share code, notes, and snippets.

@keicoder
keicoder / snippet.m
Created February 3, 2014 05:45
objective-c : Core Data : enable SQL Debug mode and disable journaling mode (WorksWellOnIOS7)
//Core Data : enable SQL Debug mode and disable journaling mode (WorksWellOnIOS7)
//enable SQL Debug mode
//1. Product > Scheme > Edit Scheme ...
//2. Ensure Run (Your App) and the Arguments tab is selected
@keicoder
keicoder / snippet.m
Last active August 29, 2015 13:55
objective-c : CoreData : fetchRequest, sortDescriptor, filter using predicate, show resulting Array object using for loop
//sample code
//CoreData : fetchRequest, sortDescriptor, filter using predicate, show resulting Array object using for loop
- (void)demo {
if (debug==1) {NSLog(@"Running %@ '%@'", self.class, NSStringFromSelector(_cmd));}
//데모 데이터
// NSArray *newItemNames = [NSArray arrayWithObjects:
// @"Apples", @"Milk", @"Bread", @"Cheese", @"Sausages", @"Butter", @"Orange Juice", @"Cereal", @"Coffee", @"Eggs", @"Tomatoes", @"Fish", nil];
//
@keicoder
keicoder / snippet.m
Created February 4, 2014 03:28
objective-c : Core Data Default Migration
//Core Data Default Migration
//1. disable automatic model mapping (just recommended option)
//set the NSInferMappingModelAutomaticallyOption option to @NO
NSDictionary *options = @{NSMigratePersistentStoresAutomaticallyOption:@YES,
NSInferMappingModelAutomaticallyOption:@NO,
NSSQLitePragmasOption: @{@"journal_mode": @"DELETE"}};
@keicoder
keicoder / snippet.m
Created February 4, 2014 01:35
objective-c : Core Data Lightweight Migration & delete journal mode
//Core Data Lightweight Migration & delete journal mode
//1. add a model version
//select current xcdatamodel -> Editor > Add Model Version -> accept new version name
//2. update data model
//select new xcdatamodel -> create a new entity -> select the new entity, create an attribute you want
//3. update current model version
@keicoder
keicoder / snippet.m
Created February 5, 2014 02:27
objective-c : 모달 뷰로 viewController 불러오기
//모달 뷰로 viewController 불러오기
//present View Controller Modally
- (IBAction)addBookmark:(id)sender {
// Initialize Add Bookmark View Controller
AddBookmarkViewController *vc = [[AddBookmarkViewController alloc] initWithNibName:@"AddBookmarkViewController" bundle:[NSBundle mainBundle]];
@keicoder
keicoder / snippet.m
Created February 5, 2014 06:31
objective-c : 클래스 생성 및 메소드 구현 예제
//클래스 생성 및 메소드 구현 예제
//.h 파일
@interface Player : NSObject {
//ivar
int score;
NSString *name;
}
@keicoder
keicoder / snippet.m
Created February 6, 2014 09:07
objective-c : 웹 뷰 이용 로컬 html 파일 불러오기
//웹 뷰 이용 로컬 html 파일 불러오기
NSString *htmlFile = [[NSBundle mainBundle]
pathForResource:@"BullsEye"
ofType:@"html"];
NSData *htmlData = [NSData dataWithContentsOfFile:htmlFile];
NSURL *baseURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
[self.webView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:baseURL];
@keicoder
keicoder / snippet.m
Last active August 29, 2015 13:56
objective-c : iOS 7 상태바 감추기 (remove the status bar on iOS 7)
//iOS 7 상태바 감추기 (remove the status bar on iOS 7)
//1. Main.storyboard -> View Controller -> Attributes inspector -> Simulated Metrics -> set Status Bar to None
//2. To remove the status bar during runtime, change necessary code
//.m file
- (BOOL)prefersStatusBarHidden {
return YES;
}
@keicoder
keicoder / snippet.m
Created February 7, 2014 03:56
objective-c : 테이블 뷰 레이블 (not embeded lable) tag 설정
//테이블 뷰 레이블 (not embeded lable) tag 설정
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ChecklistItem"];
//tag 값으로 지정하기
UILabel *label = (UILabel *)[cell viewWithTag:1000];
if (indexPath.row == 0) {
@keicoder
keicoder / snippet.m
Created February 7, 2014 01:26
objective-c : 코어 애니메이션 (Crossfade) 예제
//코어 애니메이션 (Crossfade) 예제
CATransition *transition = [CATransition animation];
transition.type = kCATransitionFade;
transition.duration = 1;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];