看板 MacDev 關於我們 聯絡資訊
這是Xcode裡HellowWorld的原始碼 - (void)drawRect:(NSRect)dirtyRect { NSString* hello=@"Hello, World!!"; NSPoint point=NSMakePoint(15, 75); NSMutableDictionary* font_attributes=[NSMutableDictionary new]; NSFont* font=[NSFont fontWithName:@"Arial" size:42]; [font_attributes setObject:font forKey:NSFontAttributeName]; [hello drawAtPoint:point withAttributes:font_attributes]; [font_attributes release]; } 想請問兩個問題是: 1. font_attributes宣告時的[NSMutableDictionary new]中的new是什麼意思? 2. [font_attributes release] 刪掉這一行程式也可執行 這一行只是為了要釋放記憶體嗎 謝謝.. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.39.168.61
Blueshiva:1.你可以直接查文件... 2.是的 05/06 15:47
istale:3w.macresearch.org/difference-between-alloc-ini-and-new 05/06 18:33
istale:不會縮網址..3W=WWW, new=alloc with basic init,參考依下 05/06 18:35