Skip to content

Instantly share code, notes, and snippets.

@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
Last active August 29, 2015 13:56
objective-c : 테이블 뷰 delegate 메소드 (사용자가 테이블 셀을 선택할 수 없도록 하기)
#pragma mark - 테이블 뷰 delegate 메소드 (사용자가 테이블 셀을 선택할 수 없도록 하기)
//static 셀이므로 셀을 탭할 수 없도록 함
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (debug==1) {NSLog(@"Running %@ '%@'", self.class, NSStringFromSelector(_cmd));}
return nil; //사용자가 테이블 셀을 선택할 수 없도록 하기
}
@keicoder
keicoder / snippet.m
Created February 8, 2014 04:27
objective-c : steps for setting up the delegate pattern between two objects
//steps for setting up the delegate pattern between two objects
//steps for setting up the delegate pattern between two objects,
//where object A is the delegate for object B and object B will send out the messages:
//1. Define a delegate @protocol for object B.
//2. Give object B a property for that delegate protocol.
//3. Make object B send messages to its delegate when something interesting happens,
//such as the user pressing the Cancel or Done buttons, or when it needs a piece of information.
//4. Make object A conform to the delegate protocol.
//It should put the name of the protocol in its @interface line and implement the methods from the protocol.
@keicoder
keicoder / snippet.m
Created February 9, 2014 09:27
objective-c : UIKit Dynamics 기초 (view, barrier, gravity, collision, elasticity, attachmentBehavior)
//UIKit Dynamics 기초 (view, barrier, gravity, collision, elasticity, attachmentBehavior)
//ViewController.m
//.m
#import "ViewController.h"
//UICollisionBehaviorDelegate : receive notifications when items collide
@interface ViewController () <UICollisionBehaviorDelegate> {
//ivars
UIDynamicAnimator* _animator;
@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
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 06:04
objective-c : AppDelegate basic code with debug
//AppDelegate basic code with debug
#import "AppDelegate.h"
@implementation AppDelegate
#define debug 1
#pragma mark - didFinishLaunchingWithOptions
@keicoder
keicoder / snippet.m
Last active August 29, 2015 13:56
objective-c : make basic table view with custom background and jason data v.1
//make basic table view with custom background and jason data
//AppDelegate.h
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (readonly, nonatomic) NSArray* sandwiches;
@end
@keicoder
keicoder / snippet.m
Created February 10, 2014 09:42
objective-c : make basic table view with custom background and jason data v.2
//make basic table view with custom background and jason data v.2
//make SandwichView (Detail View) with data
//CollectionViewLabelCell.h
@interface CollectionViewLabelCell : UICollectionViewCell
@property (nonatomic, readonly) UILabel* title;
@end
@keicoder
keicoder / snippet.m
Created February 12, 2014 03:30
objective-c : make basic table view with custom background and jason data v.3
//make basic table view with custom background and jason data v.3
//iterate over the recipes and use the addRecipeAtOffset: forSandwich: method
//to add each recipe to the view
//DynamicSandwichViewController.h
@interface DynamicSandwichViewController : UIViewController
@end