Skip to content

Instantly share code, notes, and snippets.

@0gravity000
0gravity000 / ViewController.m
Created February 24, 2016 12:02
NSDateの現在時刻について
//now に グリニッジ標準時間が格納される
NSDate* now = [NSDate date];
//now に 日本時間で格納される
NSDate* now = [NSDate dateWithTimeIntervalSinceNow:[[NSTimeZone systemTimeZone] secondsFromGMT]];
@0gravity000
0gravity000 / BundleTest.m
Created February 28, 2016 03:29
about NSBundle test code 01
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
// Get the main bundle for the app.
NSBundle* mainBundle;
mainBundle = [NSBundle mainBundle];
NSString* myImage = [mainBundle pathForResource:@"backgraund02_03" ofType:@"png"];
@0gravity000
0gravity000 / BundleTest2.m
Created February 28, 2016 03:48
about NSBundle test 2
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
// Get the main bundle for the app.
NSBundle* mainBundle;
mainBundle = [NSBundle mainBundle];
// Create folder references で追加したファイルは
// パスを指定しないとエラーになる。
@0gravity000
0gravity000 / test
Created February 28, 2016 21:48
test
test
@0gravity000
0gravity000 / SettingViewController.m
Created March 14, 2016 16:34
kitchen timer sample code 01
#pragma mark - Picker View
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)timerPicker
{
return 2;
}
@0gravity000
0gravity000 / SettingViewController.h
Last active March 15, 2016 08:16
kitchen timer sample code 01
#import <UIKit/UIKit.h>
#import "KitchenTimerViewController.h"
@interface SettingViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIPickerView *timerPicker;
@property int intPickerMin;
@property int intPickerSec;
@0gravity000
0gravity000 / SettingViewController.m
Created March 14, 2016 16:39
kitchen timer sample code 02
- (NSInteger)pickerView:(UIPickerView *)timerPicker numberOfRowsInComponent:(NSInteger)component
{
if (component == 0) {
return 60;
} else if (component == 1) {
return 60;
} else {
return 0;
}
}
- (NSString *)pickerView:(UIPickerView *)timerPicker titleForRow:(NSInteger)row
forComponent:(NSInteger)component;
{
if (component == 0) {
NSString *strMinute[] = {@"00", @"01", @"02", @"03", @"04", @"05", @"06", @"07", @"08", @"09"
, @"10", @"11", @"12", @"13", @"14", @"15", @"16", @"17", @"18", @"19"
, @"20", @"21", @"22", @"23", @"24", @"25", @"26", @"27", @"28", @"29"
, @"30", @"31", @"32", @"33", @"34", @"35", @"36", @"37", @"38", @"39"
, @"40", @"41", @"42", @"43", @"44", @"45", @"46", @"47", @"48", @"49"
, @"50", @"51", @"52", @"53", @"54", @"55", @"56", @"57", @"58", @"59"
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
self.intPickerMin = (int)[self.timerPicker selectedRowInComponent:0];
self.intPickerSec = (int)[self.timerPicker selectedRowInComponent:1];
}
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"toKitchenTimer"]) {
KitchenTimerViewController *kitchenTimer = [segue destinationViewController];
kitchenTimer.intPickerMin = self.intPickerMin;
kitchenTimer.intPickerSec = self.intPickerSec;
}
}