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*)encode:(NSString*)string{ | |
| NSString *escapedString = (NSString*)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)string, NULL, (CFStringRef)@"!*'();:@&=+$,/?%#[]", kCFStringEncodingUTF8)); | |
| return escapedString; | |
| } | |
| // デコード | |
| -(NSString*)decode:(NSString*)string{ | |
| NSString *decodedString = (NSString*)CFBridgingRelease(CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault, (CFStringRef)string, CFSTR(""), kCFStringEncodingUTF8)); | |
| return decodedString; |
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
| // テーブルの再描画 | |
| - (void)reloadData; |
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 *string =@"hogehogehoge"; // 置換対象文字列 | |
| NSString *template = @"<br/>"; // 置換後文字列 | |
| NSString *replaced = [string stringByReplacingOccurrencesOfString:@"\n" withString:template]; | |
| // 文字列検索 <en-note>の開始位置を調べる | |
| NSString *pattern = @"<en-note>"; | |
| NSRange rangeFrom = [content rangeOfString:pattern]; | |
| if(rangeFrom.location == NSNotFound){ | |
| return 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
| // 検索条件を設定する | |
| EDAMNoteFilter *filter = [[EDAMNoteFilter alloc]init]; | |
| NSString *keyword = @"fileName:fuga.txt"; | |
| [filter setWords:keyword]; | |
| // NotesMetadataResultSpec | |
| EDAMNotesMetadataResultSpec *resultSpec = [[EDAMNotesMetadataResultSpec alloc]init]; | |
| [resultSpec setIncludeTitle:YES]; | |
| [resultSpec setIncludeNotebookGuid:YES]; | |
| [resultSpec setIncludeTagGuids:YES]; |
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
| // EDAMNoteの作成 | |
| NSMutableDictionary *condition = [NSMutableDictionary dictionary]; | |
| [condition setObject:@"sample note2" forKey:@"noteTitle"]; | |
| EDAMNote *note = [self createEDAMNote:condition]; | |
| // guidの設定 | |
| NSString *guid = [[[metadata notes] objectAtIndex:0] guid]; | |
| note.guid = guid; | |
| // Update Note |
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
| ## test method | |
| def test_method(str) | |
| puts str | |
| return str | |
| end | |
| ## call method | |
| str = test_method("aaaaaa") |
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
| ## while文 | |
| while 条件式 do | |
| 実行する処理1 | |
| 実行する処理2 | |
| end | |
| ## for文 | |
| for 変数 in オブジェクト do | |
| 実行する処理1 | |
| 実行する処理2 |
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 = "hoge" | |
| b = "fuga" | |
| puts "#{a}と#{b}はほげふがです" | |
| # 置換 | |
| s = "Apple Banana Apple Orange" | |
| p s.sub("Apple", "Pine") #=> "Pine Banana Apple Orange" | |
| p s.gsub("Apple", "Pine") #=> "Pine Banana Pine Orange" |
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 = [1,2,3,4,5] | |
| a.select{|x| x%2 == 0 } => [2,4] | |
| ## 要素の追加 | |
| a = [1, 2, 3,] | |
| a << 99 #=> [1,2,3,4,5,99] | |
| a.unshift(99) #=> [99,1,2,3,4,5,99] | |
| a = [1, 2, 3, 4, 5] |
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
| NSTask *task = [[NSTask alloc] init]; | |
| // 標準出力用 | |
| NSPipe *outPipe = [NSPipe pipe]; | |
| [task setStandardOutput:outPipe]; | |
| // 標準エラー用 | |
| // 標準出力用と同じNSPipeをsetしても良いけど、分けておくと結果がエラーになったかどうかが分かる。 | |
| NSPipe *errPipe = [NSPipe pipe]; | |
| [task setStandardError:errPipe]; |