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 8744703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:53:03+00:00 2026-06-13T11:53:03+00:00

I’m prototyping an app and I’d like to have multiple .nib layout files to

  • 0

I’m prototyping an app and I’d like to have multiple .nib layout files to let friends try out different layouts to see what works the best for them.

I already have code to properly switch between a hardcoded array of known .nib files but I’d like to expand my knowledge overall so thought I’d just try to write a general system that can find all .nib files in the bundle so I don’t have to change any code if I add a new .nib layout.

I see that the paths for a given resource is really the full path. Something like:

/var/mobile/Applications/69B85DBB-3B79-43F0-B88E-FFFF/TestApp.app/en.lproj/some_asset.nib

I tried loading a .nib using the full path name and it doesn’t work as far as I can tell. The only thing that seems to work is stripping off the path and the extension to just get down to the resource name?

If so, then I have the following:

NSArray *availableNibs = [[NSBundle mainBundle] pathsForResourcesOfType:@"nib"
                                                            inDirectory:nil];

// Just grab the first .nib as a test and remove the .nib extension
NSString *aNib = [availableNibs[0] stringByReplacingOccurrencesOfString:@".nib"
                                                             withString:@""];

// Start at the end of the string and find the first '/'
for (NSInteger index = [aNib length] - 1; index >= 0; --index) {
    if ([aNib characterAtIndex:index] == '/' ) {
        // Get us down to the resource name - return string starting after that '/'
        aNib = [aNib substringFromIndex:index + 1];
        break;
    }
}
// have resource name in 'aNib', so open
self.viewController = [[My_ViewController alloc] initWithNibName:aNib
                                                          bundle:nil];

Maybe my expectations were wrong but this seems clumsier than I had expected? Is there an easier way to extract the resource names, maybe using less code?

And generally, are there any other pitfalls I might be aware of with trying to do this sort of thing or is this roughly the right approach?

Cheers in advance

  • 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-06-13T11:53:03+00:00Added an answer on June 13, 2026 at 11:53 am

    Try

    NSString *nibPath = availableNibs[0];
    NSString *nibName = [[nibPath lastPathComponent] stringByDeletingPathExtension];
    self.viewController = [[My_ViewController alloc] initWithNibName:nibName bundle:nil];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have thousands of HTML files to process using Groovy/Java and I need to
I have a bunch of posts stored in text files formatted in yaml/textile (from
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace

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.