Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 8, 2009, 02:07 AM   #1
Howiieque
macrumors regular
 
Join Date: Feb 2009
about awakefromnib

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 is offline   0 Reply With Quote
Old Feb 8, 2009, 02:45 AM   #2
Howiieque
Thread Starter
macrumors regular
 
Join Date: Feb 2009
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.
Howiieque is offline   0 Reply With Quote
Old Feb 8, 2009, 11:31 AM   #3
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
Quote:
Originally Posted by Howiieque View Post
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.

Quote:
Originally Posted by Howiieque View Post
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.
kainjow is offline   0 Reply With Quote
Old Feb 8, 2009, 07:58 PM   #4
Howiieque
Thread Starter
macrumors regular
 
Join Date: Feb 2009
thank you so much. your answer is clear and get to the point.
Howiieque is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Forum Jump

All times are GMT -5. The time now is 11:49 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps