作者jangin (我)
看板MacDev
标题[问题] Xcode程式 Memory Manage的问题
时间Mon Apr 11 16:14:23 2011
各位前辈们,请问一个问题
在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