Skip to content

Interface Builder Outlets

Question

How to get access to view/controls created in Interface Builder in c#?

Short interview answer

Connect the Interface Builder control to an outlet on the corresponding view controller or view class; the binding generates a C# member that is populated when the storyboard or nib is loaded.

Detailed answer

The outlet belongs to the object that owns the scene and is populated when Interface Builder loads it:

partial class ProfileViewController : UIViewController
{
    [Outlet] UILabel NameLabel { get; set; } = null!;
}

Give it a meaningful name, connect it in Interface Builder, and access it after the view has loaded. The outlet represents a UI element, not application state; keep durable state in the model or view model.

Sources