我只是在更新我的一个应用程序,我发现了一些让我大吃一惊的旧代码。我的评论通常很冗长,但我没有向自己解释我为什么这样做。
我正在展示一个 ModalView 并更新标题和 UITextField,如下所示:
addStoryItem.placeholderText = @"Foo"; //The text is always a static string.
addStoryItem.modalTitleText = @"Bar";
在模态中,为这两个值分配了属性:
@property (readwrite, assign) NSString *placeholderText;
@property (readwrite, assign) NSString *modalTitleText;
然后在模态被解除后在模态的 dealloc 中释放:
[placeholderText release];
[modalTitleText release];
这是安全/明智/好吗?我想我可能这样做是为了避免保留周期。