Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What awakeFromNib really is?

I'm just a newbie of Objective C iPhone programming... I see a lot of codes that contains method named "awakeFromNib".. What does it really mean? how and when and where to call this method? Thanks...

like image 535
Aldee Avatar asked Jan 23 '12 14:01

Aldee


2 Answers

awakeFromNib is called for objects (views, controllers, etc.) that are being archived in xib/nib files. This basically means that xib/nib was unarchived, all connections (IBActions/IBOutlets) for all objects are made and you have a working object graph.

I use it when I have a custom view class that I gave to a certain view in my xib.

like image 52
Eimantas Avatar answered Nov 18 '22 15:11

Eimantas


You don't call it. After nib file load, every view inside of it, be it button, UIView or something else, calls awakeFromNib from their respective class automatically. You override this method for setup and layout, as you would do with init method if you were creating a subview programmatically.

like image 1
Kyr Dunenkoff Avatar answered Nov 18 '22 14:11

Kyr Dunenkoff