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
| // Comboboxを初期化 | |
| [_directoryField selectItemAtIndex:0]; | |
| // Comboboxの選択されているindexを取得 | |
| [_directoryField indexOfSelectedItem] | |
| // NSWidowを半透明に(0.0 ~ 1.0) | |
| [_window setAlphaValue:1.0]; | |
| // 背景を設定 |
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
| // ファイルマネージャを作成 | |
| NSFileManager *fileManager = [NSFileManager defaultManager]; | |
| // ファイルが存在するか? | |
| if ([fileManager fileExistsAtPath:filePath]) { // yes | |
| NSLog(@"%@は既に存在しています", filePath); | |
| } else { | |
| NSLog(@"%@は存在していません", filePath); | |
| } |
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
| -- dual table | |
| select 1; | |
| -- JST現在時刻を出力 | |
| select strftime('%Y-%m-%d %H:%M:%S', datetime('now', 'localtime')) as strftime; | |
| -- UTC時刻 | |
| select datetime('now'); | |
| select datetime('now', 'utc'); |
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
| // 三項演算子例文 | |
| NSString *str = (a==b)?@"true":@"false"; | |
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
| // 空の可変ディクショナリ生成例 | |
| NSMutableDictionary *mdic = [NSMutableDictionary dictionary]; | |
| // 値とキー値を指定した生成例 | |
| NSDictionary *dic = [NSDictionary dictionaryWithObject:@"hoge" forKey:@"Key"]; | |
| // 値とキー値を複数指定する生成例 | |
| NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys: | |
| @"hoge", @"name", | |
| @"999-9999-9999", @"tel", |
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
| // short型→NSNumber型 | |
| NSNumber *num = [NSNumber numberWithShort:32767]; | |
| // int型→NSNumber型 | |
| NSNumber *num = [NSNumber numberWithInt:2147483647]; | |
| // long型→NSNumber型 | |
| NSNumber *num = [NSNumber numberWithLong:2147483647]; | |
| // float型→NSNumber型 |
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
| /* | |
| * save | |
| */ | |
| -(void)save{ | |
| NSError *error = nil; | |
| if (![[self managedObjectContext] commitEditing]) { | |
| NSLog(@"%@:%@ unable to commit editing before saving", [self class], NSStringFromSelector(_cmd)); | |
| } | |
| if (![[self managedObjectContext] save:&error]) { | |
| [[NSApplication sharedApplication] presentError:error]; |
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
| // autorelease onで生成 | |
| NSMutableArray *Array = [NSMutableArray array]; | |
| // autorelease offで生成 | |
| NSMutableArray *Array = [[NSMutableArray alloc] init]; | |
| NSMutableArray *Array = [[NSMutableArray alloc] initWithObjects: nil]; | |
| // 配列の作成 | |
| NSArray *ar = [NSArray arrayWithObjects:@"東京", @"名古屋", @"大阪", nil]; |
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
| // 空のNSMutableStringを生成 | |
| NSMutableString *mstr = [NSMutableString string]; | |
| // 文字列を指定した生成 | |
| NSString *str = @"hoge" | |
| if(str != nil){ | |
| NSMutableString *mstr = [NSMutableString stringWithString:str]; | |
| } | |
| // 文字列を追加 |