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.