Skip to content

Instantly share code, notes, and snippets.

@keicoder
keicoder / snippet.m
Last active April 7, 2024 13:08
objective-c : iOS 7 스토리보드 대신 xib 방식으로 개발하기
//iOS 7 스토리보드 대신 xib 방식으로 개발하기
//solution 1
1. empty application 생성
2. new class file 생성 -> name : ViewController, UIViewController sub class, with XIB check
3. appdelegate 헤더 파일 수정
@class ViewController;
@property (strong, nonatomic) ViewController *viewController;
4. appdelegate m 파일 수정
@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 / UITextView subclass for supporting string, regex search and highlighting.m
Created March 14, 2014 10:42
objective-c : UITextView subclass for supporting string, regex search and highlighting
//UITextView subclass for supporting string, regex search and highlighting
//Created by Ivano Bilenchi on 05/11/13
//ICAppDelegate.h
@interface ICAppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
@keicoder
keicoder / snippet.m
Created February 20, 2014 04:47
objective-c : delegate pattern
//delegate pattern
//delegate pattern is commonly used to handle the following situation
//ex)
//screen A opens screen B and at some point screen B needs to communicate back to screen A, for example when it closes.
//The solution is to make A a delegate of B so screen B can send its messages to A whenever it needs to.
//Screen A launches screen B and becomes its delegate
//The cool thing about the delegate pattern is that screen B doesn’t really know anything about screen A.
//It just knows that some object is its delegate. Other than that, screen B doesn’t care who that is. Just like UITableView doesn’t really care about your view controller, only that it delivers table view cells when the table view asks for them.
@keicoder
keicoder / snippet.m
Created February 22, 2014 09:08
objective-c : count items
//count items and update table views lable
//loops through the ChecklistItem objects from the items array
//If the item object has its checked property set to NO, increment the local variable count by 1
//When looked at all the objects, return the value of this count to the caller
//Checklist.h
- (int)countUncheckedItems;
//Checklist.m
@keicoder
keicoder / dealing with UIImagePickerController and UIActionSheet.m
Created March 21, 2014 07:24
objective-c : dealing with UIImagePickerController and UIActionSheet
//dealing with UIImagePickerController and UIActionSheet
//ImageViewController.h
@interface ImageViewController : UIViewController
@end
@keicoder
keicoder / Locations.m
Created March 2, 2014 06:32
objective-c : getting locaton
//getting locaton
//1. MyLocations Project Settings
//use tab bar controller
//import CoreLocation.framework
//CurrentLocationViewController.h
#import <CoreLocation/CoreLocation.h>
@keicoder
keicoder / snippet.m
Last active May 13, 2021 14:02
objective-c : dataModel using plist file and save to documents directory
//dataModel using plist file and save to documents directory
#import "DataModel.h"
#import "Checklist.h" //first time runs the app then create a new Checklist object
@implementation DataModel
#define debug 1
#pragma mark - 다큐먼트 디렉토리
@keicoder
keicoder / snippet.m
Created January 9, 2014 04:13
objective-c : assign and copy properties
assign and copy properties
Property with ’retain (or strong)’ attribute must be of object type
so, declare a property as assign if it has a primitive value
@property (nonatomic, assign) int someNumber;
You also use assign for structs, because they aren’t objects either
@property (nonatomic, assign) CLLocationCoordinate2D coordinate;
@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) 꾸미기(필수)