Skip to content

Instantly share code, notes, and snippets.

@keicoder
keicoder / launch with Xib for iPhone and iPad.m
Created March 13, 2014 09:47
objective-c : launch with Xib for iPhone and iPad
//launch with Xib for iPhone and iPad
//ex 1.
//DLAppDelegate.h
@class DLViewController;
@interface DLAppDelegate : UIResponder <UIApplicationDelegate>
@keicoder
keicoder / Note with Core Data (SwiftNote5).m
Created March 13, 2014 04:47
objective-c : Note with Core Data (SwiftNote5)
//Note with Core Data (SwiftNote5)
//1. save, delete, edit note with coredata (AddNoteView, TableView)
//AppDelegate.h
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@keicoder
keicoder / two ways of making UITableView Cell.m
Created March 13, 2014 01:52
objective-c : two ways of making UITableView Cell
//two ways of making UITableView Cell
//ex
//1. much simpler
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
@keicoder
keicoder / Basic delegate pattern.m
Created March 12, 2014 11:11
objective-c : Basic delegate pattern
//Basic delegate pattern
//AppDelegate.h
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
@keicoder
keicoder / graphics and animations on iOS.m
Created March 12, 2014 10:34
objective-c : graphics and animations on iOS
//graphics and animations on iOS
//drawRect vs. setNeedsDisplay
//When a view is refreshed, the drawRect function for that view is called. This function draws content to the view every time it is called. Because drawRect is called often, it should be a very lightweight. Don’t allocate memory in drawRect, and never call drawRect directly from your code. (We will discuss overriding drawRect further in Chapter 8, Creating Custom UIViews and UIViewControllers.)
//So, if you can’t call drawRect from your code, how do you refresh a view? The answer is to call the function setNeedsDisplay. Because resources are scarce on mobile devices, iOS attempts to optimize resource intensive processes whenever possible. Drawing content to the screen can require a lot of resources. Instead of manually calling drawRect to refresh a view, set the view as setNeedsDisplay. When a view has the setNeedsDisplay flag set, iOS automatically refreshes the view when it is most efficient. The time delay between drawRect and setNeedsDisp
@keicoder
keicoder / prepareForSegue method.m
Created March 12, 2014 10:19
objective-c : prepareForSegue method
//prepareForSegue method
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"addCourse"]) {
//ex
//1. to typical view controller with modal segue
//AddCourseViewController *acvc = (AddCourseViewController *)[segue destinationViewController];
@keicoder
keicoder / Core Data Essential (CDCourses).m
Created March 11, 2014 04:33
objective-c : Core Data Essential (CDCourses)
//Core Data Essential (CDCourses)
//Course.h
#import <CoreData/CoreData.h>
@interface Course : NSManagedObject
@property (nonatomic, retain) NSString * title;
@keicoder
keicoder / making basic UICollectionView.m
Created March 10, 2014 08:15
objective-c : making basic UICollectionView
//making basic UICollectionView
//UICollectionView 주요 메소드 (UITableView와 비교)
//UICollectionView vs UITableView
//Item(Cell) 갯수(필수)
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
//Item(Cell) 꾸미기(필수)
@keicoder
keicoder / get image in bundle on certain condition.m
Created March 10, 2014 03:40
objective-c : get image in bundle on certain condition
//get image in bundle on certain condition (특정 조건에 따라 번들에 포함된 이미지 가져오기)
//BJDCard.h
#import <Foundation/Foundation.h>
typedef enum : int
{
BJCardSuitClub = 0,
@keicoder
keicoder / Custom UITextView with JavaScript Core.m
Created March 10, 2014 00:43
objective-c : Custom UITextView with JavaScript Core
//Custom UITextView with JavaScript Core
//1. Setting up the console
//ConsoleTextView.h
@interface ConsoleTextView : UITextView
- (void)setText:(NSString *)text concatenate:(BOOL)concatenate;