Releasing dynamically added UILabel
I am adding a no. of UILable dynamically to my view like thi开发者_如何转开发s
UILabel *test = [[UILabel alloc] initWithFrame:CGRectMake(x, y, 50, 50)];
[self.view addSubview:tick];
Is it necessary to release these UILabel from memory in viewDidUnLoad and dealloc, if yes how i will release them? how i will get their reference?
Yes.
Since self.view
already -retain
ed the label in -addSubview:
, you can -release
it immediately.
UILabel *test = [[UILabel alloc] initWithFrame:CGRectMake(x, y, 50, 50)];
[self.view addSubview:test];
[test release]; // <--
精彩评论