UIButton - should we release or not?

I want to add a view button dynamically. Here is the code.

UIButton *x=[UIButton buttonWithType:UIButtonTypeRoundedRect];

I did not use the "alloc" function here.

The questions for these statements are as follows.

  • If we use imageview for the same situation, we need to create a temp imageview to add to your current view and release it. What to do for the button?
  • How are buttons allocated and unlocked?
  • If the buttons are highlighted? How to manage memory?
  • Now that I am using [x release]; - Right or wrong?
+5
source share
3 answers

alloc/init new, , . UIView, , .

+10

release . , .
alloc/init, .

+1
UIButton *x=[UIButton buttonWithType:UIButtonTypeRoundedRect];

using this method u can not relese button

instead of using

UIButton *x = [[UIButton alloc]init];

and then release

0
source

All Articles