hiragram no blog






Prepares the receiver for service after it has been loaded from an Interface Builder archive, or nib file.

Interface Builder archiveもしくはnibファイルから読み込まれたあとに、サービスに必要なレシーバを用意します

The nib-loading infrastructure sends an awakeFromNib message to each object recreated from a nib archive, but only after all the object in the archive have been loaded and initialized.

nib読み込み基盤はnib archiveから再生成されるオブジェクトが読み込まれ、初期化されたあとにawakeFromNibメッセージを送ります。

When an object receives an awakeFromNib message, it is guaranteed to have all its outlet and action connections already established.


You must call the super implementation of awakeFromNib to give parent classes the opportunity to perform any additiional initialization they require.

親クラスが必要とする初期化を実行するために、super classのawakeFromNibを呼びださなければいけません。

Although the default implementation of this method does nothing, many UIKit classes provide non-empty implementations.


You may call the super implementation at any point during your own awakeFromNib method.

super classのawakeFromNibを呼び出すのは、自分のawakeFromNibメソッド内のどこでも良いです。

NOTE During Interface Builder's test mode, this message is also sent to objects instantiated from loaded Interface Builder plug-ins.

Because plug-ins link against the framework containing the object definition code, Interface Builder is able to call their awakeFromNib method when present.

The same is not true for custom objects that you create for your Xcode projects.

Interface Builder knows only about the defined outlets and actions of those objectsl it does not have access to the actual code for them.


During the instantiation process, each object in the archive is unarchived and then initialized with the method befitting its type.


Objects that conform to the NSCoding protocol (including all subclasses of UIView and UIViewController) are initialized using their initWithCoder: method.


All objects that do not conform to the NSCoding protocol are initialized using their init method.


After all objects have been instantiated and initialized, the nib-loading code reestablishes the outlet and action connections for all of those objects.


It then calls the awakeFromNib method of the objects.


For more detailed information about the steps followed during the nib-loading process, see Nib Files in Resource Programming Guide.

もっとnib読み込み処理の続きを知りたかったらResource Programming GuideのNib Filesの項を見てな。

IMPORTANT Because the order in which objects are instantiated from an archive is not guaranteed, your initialization methods should not send messages to other objects in the hierarchy.


Messages to other objects can be sent safely from within an awakeFromNib method.

awakeFromNibメソッド内では他のオブジェクトに安全にメッセージを送ることが出来ます。 (= 既に初期化が済んでることが保証されているから、かな)

Typically, you implement awakeFromNib for objects that require additional set up that cannot be done at design time.

一般に、デザイン時に出来ない (= xib上で出来ない?) セットアップをする処理をawakeFromNibに実装します。

For example, you might use this method to customize the default configuration of any controls to match user preferences or the values in other controls.


You might also use it to restore individual controls to some previous state of your application.