This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 3秒スリープ | |
| [NSThread sleepForTimeInterval:3]; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // DB設定情報 | |
| NSString *databaseName = @"main.db"; | |
| NSString *path = @"/tmp"; | |
| NSString *databasePath = [path stringByAppendingPathComponent:databaseName]; | |
| FMDatabase *db = [FMDatabase databaseWithPath:databasePath]; | |
| // Query | |
| NSString *sql = @"select hoge1, hoge2 participants from hoge;"; | |
| // Open DB |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * main | |
| */ | |
| - (void)run{ | |
| // タイマーで使うデータ | |
| NSNumber *number = [[NSNumber alloc] initWithInt:1]; | |
| NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithObject:number forKey:@"count"]; | |
| // タイマーを作成 | |
| NSTimer *timer = [NSTimer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 現在時間を取得 | |
| NSDate *now = [NSDate date]; | |
| NSLog(@"now:%@", [now toLocalTime]); // now:2013-06-01 00:19:46 +0000 | |
| // 現在時間にインターバル時間を足す | |
| NSTimeInterval interval = 3600; // 秒 | |
| NSDate *after = [now dateByAddingTimeInterval:interval]; | |
| NSLog(@"after:%@", [after toLocalTime]); // after:2013-06-01 01:19:46 +0000 | |
| // 時間の判定 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @interface NSDate (Util) | |
| - (NSDate*)toLocalTime; | |
| @end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| a = "foo bar baz" | |
| puts a | |
| puts a.scan(/f+/) | |
| puts "========" | |
| b = "foo 10 bar 20 baz 30" | |
| puts b | |
| puts b.scan(/\w+/) | |
| puts "========" |
NewerOlder