[問題] Xcode程式 Memory Manage的問題
各位前輩們,請問一個問題
在MyViewController.h檔中
@interface MyViewController:UIViewController {
IBOutlet UITextField *pageinfo_display;
}
@end
在MyViewController.m中
@interface MyViewController()
int currentPage;
int totalPage;
@end
@implement MyViewController
-(void) updatePageInfo
{
pageinfo_display.text = [[NSString alloc] initWithFormat:
@"%d / %d",currentPage,totalPage];
}
@end
我的問題是
(1) pageinfo_display.text = ...
(這樣子setter 是不是會自動先做Release 再做新的NSString指定)
記得在斯坦福的線上影片曾看到 setter 會是 先做Release 再assign.
不知道自己有沒有會錯意,影片是英文的@@
(2) 還是在等於的後面的NSString alloc 加上autoRelease
[[[NSString alloc] initWithFormat:
@"%d / %d",currentPage,totalPage]autorelease];
(3) 1和2 都不對,請各位前輩幫忙解說一下,非常感謝。
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.120.179.30
討論串 (同標題文章)
以下文章回應了本文 (最舊先):
完整討論串 (本文為第 1 之 3 篇):
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章