Search code examples
iosobjective-ciboutlet

Where to customise IBOutlets


Where should I customise my IBOutlets?

Say I have created a button with interface builder, created an IBOutlet for it and I would want to change a property during runtime (ex: background color or localized title).

I would think of adding it to the viewDidLoad method, but outlets aren't yet created. I remember having nil outlets in viewDidLoad, but I might be wrong.

If I move it viewWillAppear, the code will be executed every time the view controller's view appears.

Is there any better place for my IBOutlet related code, so it's only executed once?


Obviously I can do just about any customization using only the interface builder and making use of the User defined runtime attributes or localized stroryboards, but I don't like that since it's much more tedious to change later.


Solution

  • From the Doc

    enter image description here

    Its clearly says about the Views loaded into the memory in the -viewDidLoad() delegate itself.