alloc initしたオブジェクトは、利用後にreleaseする。
それはわかったー。
例えば、
UILabel *lbl = [[UILabel alloc] initWithFrame:rect];
~略~
[self.view addSubView:lbl];
[lbl release];
これは、addSubViewで(メッセージレシーバー側で)retainされるので、
自分は、releaseする。
addSubViewのヘルプにのってた。
サンプルいくつか見てて気になったのが、allocしないもの。
UIButton *btn = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
~略~
[self.view addSubView:btn];
[btn release];
buttonWithTypeのヘルプ見ると、Create and returns と、書いてある。
なので、中でallocとinitされるということ だろう。
UIButtonに関しては、retainせずにaddSubViewしてるサンプルもあるので、
そのへんもなんとなくわかる。
そんなメソッドが用意されてるクラスもあると。
便利そうなautoreleaseは、あとで考えたいところ。