Nuã§Mac GUIããã°ã©ãã³ã°
ãä»åã¯Nuã使ã£ã¦ãMacã®GUIããã°ã©ãã³ã°ãè¡ãã¾ãã第1åã§ãæ¸ãã¾ããããNuã®å¤§ããªç¹å¾´ã¯Macã®ä¸»è¦éçºè¨èªã§ããObjective-Cã¨ç¸äºå¼ã³åºããã§ããäºã§ãã
ãé常ãMacã®GUIã¢ããªãä½ãå ´åã¯Objective-Cã使ãã¾ããObjective-Cã¯Cè¨èªã®ä¸ã«Smalltalk風ã®ãªãã¸ã§ã¯ãã·ã¹ãã ãä¹ãããã¤ããªãããªè¨èªã§ããã®éçºã«ã¯Xcodeã¨ããç´ æ´ãããIDEã使ãã¾ããããããããCè¨èªããã¼ã¹ã¨ãã¦ããã®ã§ãææ©ãã¢ããªãä½ããã¨ããã¨ä½ãã¨ä¸ä¾¿ã§ãã
ãããããNuã使ãã¨ä¿æãªLispããã°ã©ãã³ã°ã§æ軽ã«GUIã¢ããªãä½ãäºãã§ãã¾ããä»åã¯ãã®ç»é¢ã®ãããªã·ã³ãã«ãªTwitterã¯ã©ã¤ã¢ã³ããä½ã£ã¦ã¿ã¾ãã
ããã¾ã§ã®è¨äº
- 第1åï¼ããã°ã©ãã³ã°è¨èªNuã®åºæ¬ã¨ã¤ã³ã¹ãã¼ã«æ¹æ³
- 第2åï¼ããã°ã©ãã³ã°è¨èªNuã§Lispããã°ã©ãã³ã°ãï½Så¼ã®ä½¿ãæ¹ï½
Objecive-Cã¨Nuã®é¢ä¿
ã以ä¸ã®ã³ã¼ãã¯ä»åã®ã¢ããªãObjective-Cã§æ¸ãããã®ã®ä¸é¨ã§ããifãreturnãªã©ã®å¶å¾¡æ§é ã¯Cè¨èªã§ãã [ ... ] ã®é¨åã¯Objective-Cç¬èªã®ã¡ã½ããå¼ã³åºãã«ãªã£ã¦ãã¾ããã¾ããã¼ã¯ã¼ãå¼æ°ã®å½¢ãªã©ãSmalltalkã彷彿ã¨ããã¾ããæåã®è¡ãã¤ã³ã¹ã¿ã³ã¹ã¡ã½ããã®å®ç¾©ã«ãªãã¾ãã
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex { NSArray *tl = [[timeLines objectAtIndex:rowIndex] componentsSeparatedByString:@"\t"]; if ([[aTableColumn identifier] isEqualToString:@"icon"]) { return [[NSImage alloc] initWithContentsOfURL: [NSURL URLWithString:[tl objectAtIndex:2]]]; } else if ([[aTableColumn identifier] isEqualToString:@"name"]) { return [tl objectAtIndex:0]; } else if ([[aTableColumn identifier] isEqualToString:@"text"]) { return [tl objectAtIndex:1]; } else { return @""; } }
ãããã«ç¸å½ããNuã®ã³ã¼ãã¯ä»¥ä¸ã®ããã«ãªãã¾ãããã¼ã¿ã®æã¡æ¹ãéãã®ã§ã¾ã£ããåãã§ã¯ãªãé¨åãããã¾ããã [...] ã¯ãã®ã¾ã¾ (...) ã«ç½®ãæããã ãã ã¨ããäºãåããã¾ãã
ããã®ããã«ãNuã§ã®Cocoaï¼Mac OS APIï¼ããã°ã©ãã³ã°ã¯ãNuã®ææ³ã§ã³ã¼ããæ¸ããCocoa APIã®å¼ã³åºãé¨åã¯ããã¥ã¢ã«ãè¦ããªã©ããªãããObjective-CããNuç¨ã«ç½®ãæããã ãã§è¯ãã®ã§ãã
(- (id) tableView:(id) aTableView objectValueForTableColumn:(id) aTableColumn row:(int) rowIndex is (case (aTableColumn identifier) ("icon" ((NSImage alloc) initWithContentsOfURL: (NSURL URLWithString:(tl-icon (@timeLines objectAtIndex:rowIndex))))) ("name" (tl-name (@timeLines objectAtIndex:rowIndex))) ("text" (tl-text (@timeLines objectAtIndex:rowIndex))) (else "")))
ãã¾ããObjective-Cã¯éçãªè¨èªãªã®ã§ããªãã¸ã§ã¯ãã®ãã£ã¹ããã以å¤ã¯å¼æ°çã®åãå³å¯ã«å®ç¾©ããªãã¨ããã¾ãããã§ãããNuã¯åçãªè¨èªãªã®ã§é常ã®ãªãã¸ã§ã¯ã㯠idåã«ããã°æ¸ã¿ã¾ããããã«ããã©ã«ãã®å㯠id ãªã®ã§ (id) ã¯çç¥å¯è½ã§ãã
ããã ããObjective-Cã¯Javaã¨åãããã« int ã double ãªã©ã®ããªããã£ãã¯ãªãã¸ã§ã¯ãã§ããã¾ãããNuã¯ãã¹ã¦ããªãã¸ã§ã¯ããªã®ã§ãããªããã£ãã«å¯¾å¿ããå¼æ°ãæ»ãå¤ã¯å宣è¨ããªãã¨ããã¾ãããç¾å¨ã®Nuã§ã¯ããªããã£ãã«å¯¾å¿ããé¨åã®å®£è¨ããªãã¨ãå®è¡æã«ã»ã°ã¡ã³ãã¼ã·ã§ã³ãã©ã¼ã«ãçã§è½ã¡ãããããã¨ãããã¾ãã
ããã®ä»ã®ç´°ããç¹ã§ã¯ãObjective-Cã§ã¯æååã @"..." ã¨æ¸ãã¨ãCè¨èªãæååã§ã¯ãªã NSStringã¯ã©ã¹ã®ãªãã¸ã§ã¯ãã«ãªãã¾ãããNuã§ã¯ãã¹ã¦ã®æåå㯠NSStringã¯ã©ã¹ã®ãªãã¸ã§ã¯ãã«ãªã£ã¦ãã¾ããã¾ããNuã§ã¯ @ ããå§ã¾ãå¤æ°ã¯ã¤ã³ã¹ã¿ã³ã¹å¤æ°ã¨ãªãã¾ãã