こんにちは、次のコードの問題を知りたいです
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button release];
こんにちは、次のコードの問題を知りたいです
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button release];
次のコードは、autoreleasedオブジェクトを提供します。
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
release を呼び出すと、クラッシュします。
コードのエラーは次のとおりです。
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
この行では、 のオブジェクトを割り当てていませんUIButton。つまり、いつリリースするかを制御できません。この行は正しいです。
[button release];
この行では、button. このオブジェクトを解放するための制御は、あなたが割り当てていないため、あなたにはありません。リリースを使用する場合。次に、UIButton最初にオブジェクトを割り当てます。