[問題] 基本語法問題

看板MacDev作者時間14年前 (2010/05/06 15:40), 編輯推噓1(102)
留言3則, 2人參與, 最新討論串1/2 (看更多)
這是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

05/06 15:47, , 1F
1.你可以直接查文件... 2.是的
05/06 15:47, 1F

05/06 18:33, , 2F
3w.macresearch.org/difference-between-alloc-ini-and-new
05/06 18:33, 2F

05/06 18:35, , 3F
不會縮網址..3W=WWW, new=alloc with basic init,參考依下
05/06 18:35, 3F
文章代碼(AID): #1Bud9GsQ (MacDev)
文章代碼(AID): #1Bud9GsQ (MacDev)