PDA

View Full Version : about awakefromnib




Howiieque
Feb 8, 2009, 02:07 AM
awakefromnib: is listed in an informal protocol. apple document says that if implement an informal, i should declare again both in the interface section and the implementation section. But it seems that people just implement it in their implementation section, why?



Howiieque
Feb 8, 2009, 02:45 AM
it seems that every object from the nib file gets a awakefromnib message after being load. if i don't implement the awakefromnib method, why no error occur? it has no awakefromnib at all.

kainjow
Feb 8, 2009, 11:31 AM
awakefromnib: is listed in an informal protocol. apple document says that if implement an informal, i should declare again both in the interface section and the implementation section. But it seems that people just implement it in their implementation section, why?
Redeclaring it is unneeded because it's already declared in NSNibAwaking.h so the compiler already knows about it. If you're explicitly calling [myObject awakeFromNib] from another class you may want to declare it, but I don't know a situation where this would be needed.

it seems that every object from the nib file gets a awakefromnib message after being load. if i don't implement the awakefromnib method, why no error occur? it has no awakefromnib at all.
The nib loading class is probably calling [yourObject respondsToSelector:@selector(awakeFromNib)] before to prevent errors.

Howiieque
Feb 8, 2009, 07:58 PM
thank you so much. your answer is clear and get to the point.:)