Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why UIButton does not require to alloc and init?

Why UIButton does not require to alloc and init call instead we use only UIButton *myBtn = [UIButton buttonWithType:UIButtonTypeCustom];.

  1. Does the above line automatically alloc s and init the uibutton??
  2. Is it necessary to release myBtn?,since i'm not using alloc and init explicitly.

This may be a simple question but i don't know the correct answer for this, does anybody can help? Any help is appreciated,thanks in advance.

like image 689
George Avatar asked Jan 20 '23 00:01

George


1 Answers

Well the buttonWithType will return a type of UIButton which is alloc and init for you. It is also autoreleased.

You can als alloc and init a UIButton your self, this will give you an UIButton of type UIButtonTypeCustom.

like image 54
rckoenes Avatar answered Jan 28 '23 01:01

rckoenes