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

  • Home
  • SEARCH
  • 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 7516041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:00:30+00:00 2026-05-30T01:00:30+00:00

I have a program that creates UIViewControllers in a UISplitView depending upon which row

  • 0

I have a program that creates UIViewControllers in a UISplitView depending upon which row is selected in a UITableView. For example, if the user clicks the row called ‘settings’, the program creates a view controller called settingsTableVC (which displays in the left-hand pane of the UISplitViewController) and a detail view controller called settingsDetailVC, which appears in the right hand pane.

The logic works fine, but I have a lot of code for each row in the initial tableView, for creating and setting up each ViewController, and their public properties and it seems to me a simpler way would be to define two generic ViewControllers, then cast them to the correct type in a method. That way, I can define their public properties generically (as they are all basically the same properties, pointers to the masterViewController and the tableViewController)

E.G.

UIViewController *leftController = nil;
UIViewController *rightController = nil;'

Then, in the didSelectRowAtIndexPath:

leftController = [[SettingTableViewController alloc]init];
rightController = [[SettingsDetailViewController alloc]init];

leftController.masterVC = self;
rightController.tableVC = leftController;

However, the complier warns – ‘UIViewController does not declare a property masterVC’.

How can I change the class of these ViewControllers at runtime?

  • 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-30T01:00:31+00:00Added an answer on May 30, 2026 at 1:00 am

    You can do either of the following:

    SettingsTableViewController *leftControllerCasted = (SettingsTableViewController *)leftController;
    SettingsDetailViewController *rightControllerCasted = (SettingsDetailViewController *)rightController;
    leftControllerCasted.masterVC = self;
    rightControllerCasted.tableVC = leftController; // Doesn't matter if you assign it to leftController or leftControllerCasted
    

    or

    ((SettingsTableViewController *)leftController).masterVC = self;
    ((SettingsDetailViewController *)rightController).tableVC = leftController;
    

    You have created your objects correctly, but as you assign them a UIViewController pointer object type the compiler doesn’t know your objects are of your custom class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that creates a Windows user account using the NetUserAdd() API
I have a program that creates a JFrame and makes it visible. Is there
I have a program that creates a small file in the Bin directory for
Greetings I have a program that creates multiples instances of a class, runs the
I have a simple program that creates a thread, loops twenty times and then
I have a Delphi program that creates HTML files. Later when a button is
I have a program that starts up and creates an in-memory data model and
I have a program that creates a html file as standard output. To view
I have a program that creates a notification if the application is not running.
OK I have a program that creates two pipes -> forks -> the child's

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.