Objective-C记忆问题 [英] Objective-C Memory Question

查看:71
本文介绍了Objective-C记忆问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个视图控制器并分配这样的视图,这是泄漏吗?

Is it a leak if I have a view controller and allocate the view like this:

self.view = [[UIView alloc] initWithFrame:frame];

我需要做这样的事情吗?

Do I need to do something like this:

UIView *v = [[UIView alloc] initWithFrame:frame];
self.view = v;
[v release];

推荐答案

是的,第二个.属性( self.view )通常保留其值.

Yes, the second one. Properties (self.view) retain their value usually.

这篇关于Objective-C记忆问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆