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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:18:13+00:00 2026-05-25T06:18:13+00:00

I have subclassed a system class (UINavigationBar, to be specific) to add some specific

  • 0

I have subclassed a system class (UINavigationBar, to be specific) to add some specific functionality. I’ve been using this everywhere, as a replacement for UINavigationBar. However, now I want to replace some UINavigationBars used in system frameworks with my custom subclass, so they provide the same behaviour. In specific, I would like the UINavigationBar in the UITabBarController’s more view controller to be an instance of my class.

I thought this might be impossible, so I tried creating a category on UINavigationBar, which would propagate everywhere in the system. However, my category would need to do some custom initialisation and teardown (Subscribing and unsubscribing from a NSNotificationCenter’s notification). If I overwrite the init/dealloc methods in my category, I won’t be able to call the original methods (as implemented by UINavigationBar), which could be very dangerous/fatal/probably not very functional.

One potential solution is method swizzling, but I’m not quite sure how to use it and it could apparently be quite complicated.

If anyone’s able to elaborate on how to implement something which would solve my problems (or some custom code for how I could use method swizzling), I’d be very grateful.

  • 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-25T06:18:14+00:00Added an answer on May 25, 2026 at 6:18 am

    You can override the +allocWithZone: method on UINavigationBar class to instead create an instance of your subclass (just as a class cluster behaves), using the method_setImplementation() function (check the Objective-C Runtime Reference for more details of the function)

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

Sidebar

Related Questions

I have subclassed Form to include some extra functionality, which boils down to a
I have an abstract Class Monitor.java which is subclassed by a Class EmailMonitor.java .
I have a class that subclasses NSMutableArray. I init it using: MyClass class =
I have a framework which works this way: After defining some meta data, it
I have subclassed java.awt.Frame and have overridden the paint() method as I wish to
I have a base class with a virtual method, and multiple subclasses that override
I have a subclass s of UIView. I want to put some buttons and
I have subclassed the RadioButtonList control in order to create a Control Adapter that
I'm having this very odd issue while trying to serialize a class for logging
I'm working on a player inventory system for a game. I have a struct

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.