Skip to content

Instantly share code, notes, and snippets.

@keicoder
keicoder / snippet.m
Created March 4, 2014 02:40
objective-c : Textkit and TableView with note (ios 7)
//Textkit and TableView with note (ios 7)
//1. start with basic dummy data
//AppDelegate.h
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property NSMutableArray* notes;
@keicoder
keicoder / snippet.m
Created February 27, 2014 03:20
objective-c : Image to NSData and Reverse Transform for saving Core Data
//Image to NSData and Reverse Transform for saving Core Data
//1. CoreData 모델 생성
//ex) Entities name : Photo / Attributes : date (type Date), image (type Transformable)
//2. create NSManagedObject Subclass (in this case : TWPictureDataTransformer class)
//3. TWPictureDataTransformer.h
@interface TWPictureDataTransformer : NSValueTransformer
@keicoder
keicoder / snippet.m
Last active August 29, 2015 13:56
objective-c : snapBehavior example code
//snapBehavior example code
@implementation DynamicSandwichViewController
{
NSMutableArray* _views;
UISnapBehavior* _snap;
BOOL _viewDocked;
}
@keicoder
keicoder / snippet.m
Created February 10, 2014 03:25
objective-c : UIView animateWithDuration 블록 코드
//UIView animateWithDuration 블록 코드
[UIView animateWithDuration:.2 animations:^{
//code here
}];
@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
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
Last active August 14, 2018 05:08
objective-c : set background image of a UITableView
//set background image of a UITableView
//ViewController.m
- (void)viewDidLoad
{
[super viewDidLoad];
//Controlling the Background of a UITableView
//setting an image as the background of UITableView through four steps
@keicoder
keicoder / snippet.m
Created January 29, 2014 06:23
objective-c : iOS Simple TableView
//iOS Simple TableView
//You have to wire up data Source and delegate to the tableView in the xib file
//ViewController.h
@interface ViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
@property (nonatomic, strong) NSMutableArray *tableData; // holds the table data (title)
@property (nonatomic, strong) NSMutableArray *tableDetailData; // holds the table data (detail text)
@keicoder
keicoder / snippet.m
Created January 24, 2014 02:35
objective-c : make a property read-only to other objects but fully accessible to your own class
//make a property read-only to other objects but fully accessible to your own class
//.h file
//readonly
@property (nonatomic, readonly, strong) NSMutableArray *searchResults;
//.m file
@keicoder
keicoder / snippet.m
Created January 14, 2014 02:56
objective-c : 파일/디렉토리 삭제 (code snippet that can use to remove any file or folder)
//파일/디렉토리 삭제 (code snippet that can use to remove any file or folder)
- (void)removePhotoFile
{
NSString *path = [self photoPath];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:path]) {
NSError *error;