Skip to content

Instantly share code, notes, and snippets.

@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 25, 2014 04:50
objective-c : iOS Internationalization using NSLocalizedString()
//iOS Internationalization using NSLocalizedString()
//1. use NSLocalizedString() (even if you don’t care about internationalization right away)
//2. open a Terminal, go into the folder that contains the actual source files
//3. type command :genstrings *.m -o en.lproj
//4. above command add a new file called Localizable.strings in the en.lproj folder
//5. add Localizable.strings file to the project in Xcode (ex : Supporting Files group)
//6. in the File Inspector, add a localization for this file (in this case Dutch)
//7. Change the translations in the Localizable.strings
@keicoder
keicoder / snippet.m
Created January 28, 2014 02:43
objective-c : Adding a Background Image using backgroundColor property
//Adding a Background Image using backgroundColor property
- (void)viewDidLoad {
[super viewDidLoad];
//make a “color” based on an image using backgroundColor property
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg_img"]];
}
@keicoder
keicoder / snippet.m
Created January 28, 2014 04:49
objective-c : UIKit Customization (navBar, barButton, slider, etc)
//UIKit Customization
//.h
- (void)customizeAppearance;
//.m
- (void)customizeAppearance
{
@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
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 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 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 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"}};