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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:11:12+00:00 2026-06-11T19:11:12+00:00

I am writing a test project to learn to write everything in code. I

  • 0

I am writing a test project to learn to write everything in code. I want to do this way so that I can better understand what the Elements in Storyboard do for me behind the scene’s

In my project I have several UIViewControllers which share the same UI elements. For Example I have a UITool bar at the top of the screen with several buttons in it.

Now I want to put that UIToolbar in a separate class so that I do not have to write it all out or copy n paste it in every controller.

Now I know I can achieve this by doing this:

#import "General_Add_ons.h" //the UIToolbar is properly set up in this file

@interface FirstViewController : General_Add_ons  

and then I just use [self topToolBar]; //topToolBar is the name of the toolbar

Now I just want to clarify is this the best and or only way to this?

Somehow I feel I should be able to do this:

    General_Add_ons *gao = [[General_Add_ons alloc] init];
    [gao topToolbar];

Am I thinking about this the wrong way? The first way seems to be limiting in case I have multiple external classes.

Thanks 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-11T19:11:13+00:00Added an answer on June 11, 2026 at 7:11 pm

    Your approach seem correct. If you have several UIViewController instances that need the same UI elements or other controller code, you can put those elements in a UIViewController subclass. In your case, I believe the class General_Add_ons is the UIViewController from which your subclasses will inherit.

    This class (your General_add_ons) should have a property for the reusable toolbar, e.g.

    @property (nonatomic, strong) UIToolbar *toolbar;
    

    As an aside, class names in Cocoa, by convention are: prefix+capitalized words without underscores. Apple has a great reference on naming conventions.

    EDIT

    For clarification, you can subclass your custom subclass as many times as you need. For example in my code, I have a class CCFViewController that encapsulates common properties and behaviors that I want all of my view controllers to have. In the project, then, all of the view controllers inherit from that parent controller. Similarly, your toolbar will live in the superclass and the other controllers inherit from it.

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

Sidebar

Related Questions

I'm writing test code that needs to clean up the entities it creates when
i'm writing my first plugin, but in test project, can't resolve the class of
I am writing unit test for zend project, I want to know <?php class
currently im writing a test for a report function the more functionality the project
I'm fairly new to writing test cases and this will be my first major
We want to design a simple domain specific language for writing test scripts to
I'm writing some test cases, and I've got a test case that is using
I am writing a test app for a larger project and cant seem to
I'm writing test cases for a project which still uses the Acegi plugin (not
I'm writing JUnit test code for an android service implementation, and I have to

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.