Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7403597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:07:43+00:00 2026-05-29T05:07:43+00:00

I have a weird question: What is the pattern that the UIKit is using

  • 0

I have a weird question:
What is the pattern that the UIKit is using to figure out the right nib name for a UIViewController, when you don’t explicitly specify the nibName?

Why am I asking?

Because I thought (With a good reason) that the system will first look for the nib with the same name as the controller’s class’s.
That is, if I have a VideoViewController, the system will first look for VideoViewController.xib.

Apparently this is not the case.
I have another class, VideoView, which is a subclass of UIView. I have a nib called VideoView.xib that contains all the view hierarchy for VideoView.

When I try to run the app, it crashes immediately with setValue:ForUndefinedKey Exception.
I noticed that the key is always a key from the VideoView.xib, and not from VideoViewController.xib. That means that the system is trying to load VideoView.xib for a view controller named VideoViewController.

It seems that if the system will find a nib with a name similar the controller class name -only without the “Controller” suffix, it’ll use that nib.

I confirmed it by renaming my class to VideosViewController (With ‘s’), and everything worked just fine.

Are there any more edge conditions like this one?
Or is there a place that specify the exact algorithm?

It took me an hour to debug this one, and I don’t want to waste any more time in the future on the same problem…

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:07:44+00:00Added an answer on May 29, 2026 at 5:07 am

    From the documentation of UIViewController.nibName property:

    If you use a nib file to store your view controller’s view, it is
    recommended that you specify that nib file explicitly when
    initializing your view controller. However, if you do not specify a
    nib name, and do not override the loadView method in your custom
    subclass, the view controller searches for a nib file using other
    means. Specifically, it looks for a nib file with an appropriate name
    (without the .nib extension) and loads that nib file whenever its view
    is requested. Specifically, it looks (in order) for a nib file with
    one of the following names:

    1. If the view controller class name ends with the word “Controller”, as
      in MyViewController, it looks for a nib file whose name matches the
      class name without the word “Controller”, as in MyView.nib.
    2. It looks
      for a nib file whose name matches the name of the view controller
      class. For example, if the class name is MyViewController, it looks
      for a MyViewController.nib file.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Weird question, perhaps. We have a number of simple utilities written in-house that need
Weird question, but I'm not sure if it's anti-pattern or not. Say I have
So, I think I have a very weird question. So, let say that I
This might be a weird question but I'm trying to figure out why the
I have a weird Scheme question. This is a part of something bigger that
Hi guys I have a weird question, I have a cli php script runs
Sounds like a weird question, but say I have something like this: $.post( /myajax.php,
Kind of a weird question, but. I need to have a list of strings
Hi this may seem like a weird question, but here's my situation: I have
OK, this is a slightly weird question. We have a touch-screen application (i.e., no

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.