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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:27:52+00:00 2026-06-15T18:27:52+00:00

We are subclassing UITabBarController as well as UITabBarControllerDelegate to handle certain events concerning tab

  • 0

We are subclassing UITabBarController as well as UITabBarControllerDelegate to handle certain events concerning tab switches.

Now in our custom tab bar controller we have:

- (id)initCustomTabBarController {
    self = [super init];
    if(self) {
       [self setDelegate:[[CustomTabBarControllerDelegate alloc] init]];
       // ...
    }
    return self;
}

Since we transitioned the project to ARC, the delegate is released to early which causes a tab switch run into a deallocated instance.

The property is defined as assign in UITabBarController.h – which I obviously have no influence on.

What can I do to make the delegate object “live” longer than for the init method?

  • 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-15T18:27:53+00:00Added an answer on June 15, 2026 at 6:27 pm

    The way you have done it, it is expected that the delegate will not outlive the object, because it is weak. Remember, you created the object, it’s up to you to hold on to it.

    However – the pattern that you are using is incorrect.

    The point of a delegate, is that it provides method implementations to a class that a class can’t add for itself, because it doesn’t have enough information. For example, a table view delegate. A table view, in order to be generic, cannot know how many rows or sections to display, so it asks it’s delegate to supply this information.

    In your case, you have an object that is creating it’s own delegate. In which case, why bother having a delegate at all? Just implement the methods in the class.

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

Sidebar

Related Questions

I'm subclassing QProgressBar in a custom widget, and I overwrote the paintEvent method with
I created a new custom TableViewCell by subclassing UITableViewCell. I created a table view
I'm subclassing UITextField and want to assign to its rightView property a custom button.
I am currently subclassing UIView to create custom objects, they work perfectly fine In
I currently am subclassing a UILabel to change the font to a custom font,
If I have a custom class subclassing Sprite and it draws some simple objects,
I have created a custom event in my Qt application by subclassing QEvent. class
I have a custom NSCell (actually subclassing NSTextFieldCell ), which is used both in
I am subclassing a UIView and am calling it via a detail view controller.
I have a UITabBarController, and each tab handles a different UIViewController that pushes on

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.