作者istale (一天一次的嘆息,快用光ꜩ
看板MacDev
標題[問題] 基本語法問題
時間Thu May 6 15:39:57 2010
這是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
1F:推 Blueshiva:1.你可以直接查文件... 2.是的 05/06 15:47
2F:→ istale:3w.macresearch.org/difference-between-alloc-ini-and-new 05/06 18:33
3F:→ istale:不會縮網址..3W=WWW, new=alloc with basic init,參考依下 05/06 18:35