iPhone PushViewController 发布

发布于 2024-10-10 06:25:21 字数 287 浏览 1 评论 0原文

当我调用时:

        ChooseDateView *nextController = [[ChooseDateView alloc] initWithNibName:@"ChooseDateView" bundle:nil];
        [self.navigationController pushViewController:nextController animated:YES];

是否有必要调用[nextController release]?

谢谢

when i call:

        ChooseDateView *nextController = [[ChooseDateView alloc] initWithNibName:@"ChooseDateView" bundle:nil];
        [self.navigationController pushViewController:nextController animated:YES];

is it necessary to call [nextController release]?

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

兮颜 2024-10-17 06:25:21

是的,有必要调用

[nextController release]

otherWise make 对象作为自动释放

ChooseDateView *nextController = [[[ChooseDateView alloc] initWithNibName:@"ChooseDateView" bundle:nil] autorelease];

Yes it is neccessary to call

[nextController release]

otherWise make object as an autorelease

ChooseDateView *nextController = [[[ChooseDateView alloc] initWithNibName:@"ChooseDateView" bundle:nil] autorelease];
一指流沙 2024-10-17 06:25:21

必须要调用【nextControllerrelease】,不然分配的内存怎么释放呢?

It is necessary to call [nextController release], otherwise how will the allocated memory be released?

浮世清欢 2024-10-17 06:25:21

是的。

您只能释放或自动释放您拥有的对象。

如果您满足以下条件,您就获得了对象的所有权:
使用其名称的方法创建它
以“alloc”或“new”开头或
包含“复制”(例如,分配,
newObject 或 mutableCopy),或者如果您
向其发送一条保留消息。

您使用release或autorelease来
放弃对象的所有权。
autorelease 只是意味着“发送一个版本
未来的消息”(理解
当出现这种情况时,请参阅“自动释放
池”)。

内存管理规则

Yes.

You only release or autorelease objects you own.

You take ownership of an object if you
create it using a method whose name
begins with “alloc” or “new” or
contains “copy” (for example, alloc,
newObject, or mutableCopy), or if you
send it a retain message.

You use release or autorelease to
relinquish ownership of an object.
autorelease just means “send a release
message in the future” (to understand
when this will be, see “Autorelease
Pools”).

Memory Management Rules

烟花肆意 2024-10-17 06:25:21

既然您已经分配了内存,那么您就是该对象的所有者。同样在分配之后,该对象将使用pushViewController 进行推送。这样我们就可以安全地释放该对象了。
由于您拥有该对象,因此必须这样做。
您也可以自动释放它。

Since you have allocated the memory, you are the owner of the object. Also after allocation, that object is pushed using pushViewController. So we can safely release the object.
and it is must to do since you own the object.
You can also autorelease it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文