Object attribute in Nib/Xib file I didn’t pay attention to

I usually set options and attributes from the Interface Builder, instead of doing so in source codes. It is because things are visually set and can reduce the amount of coding. It feels more modular to me.

However, there are several attributes which are not quite clear to understand. One of such thing is “User Defined Runtime Attributes”.

Runtime Attributes

First, what does “User Defined” mean here? Second, what is “Runtime Attributes”?

There is no balloon help for that. So, I looked up the document, and would like to explain here more easily.

For custom classes, you would not spend your time to create IB inspector plugins to set properties/attributes, or their member variables usually. Then in -(id)init or -(void)awakeFromNib messages, you would initialize those.
However, if you want to initialized those when they are loaded from a nib/xib file automatically?

Then you can specify those class attributes, or properties there under “User Defined Runtime Attributes”.
In OOP term, a property of a class is realized as a member variable. In this case, it is different from IBOutlets. It is just member variable.

So, setting those under “User Defined Runtime Attributes” has same effect to setting those in -(void)awakeFromNib, because the the -(void)wakeFromNib is called when the Nib/Xib is loaded.

It is up to us, programmers, whether to do so in -(void)awakeFromNib or there using Interface Builder. Which one do you prefer? It can be different case by case. But in my case, I have used the -(void)awakeFromNib.

Do you use the “User Defined Runtime Attributes” setting often? Then when you think it is better than -(void)awakeFromNib?


2 responses to this post.

  1. Posted by Rainer Standke on April 14, 2011 at 9:19 AM

    These things are useful when you need to set the initial value of something per instance, rather than identically for all instances. It provides away to figure out which of several identical UI elements you’re looking at, e.g. when an action message is received.


    • Posted by jongampark on April 14, 2011 at 9:50 AM

      Thanks for leaving a comment.
      Well, I use “tag” for identifying widgets, or UI elements. Because “tag” is made for that purpose.


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: