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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:06:50+00:00 2026-06-10T00:06:50+00:00

I have a UIViewController which contains this property: @property (weak, nonatomic) IBOutlet UITableView *customerTableView;

  • 0

I have a UIViewController which contains this property:

@property (weak, nonatomic) IBOutlet UITableView *customerTableView;

In the UIViewController’s viewDidLoad method, I have the following:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // ...
    CustomerTableViewDataSource *dataSource = [[CustomerTableViewDataSource alloc]
        init];
    [dataSource setData:customersSource];
    [customerTableView setDataSource:dataSource];
}

I receive this with NSZombies enabled:

*** -[CustomerTableViewDataSource numberOfSectionsInTableView:]: message sent to 
deallocated instance 0x3e07a0

The deallocated instance address is the same as the data source.

Is there any reason why the data source isn’t ‘sticking’?

Using the simulator and Zombies, I see that the reference is being released in viewDidLoad, which I suppose is no surprise since I declared it in that method and it should fall out of scope, however I would think that calling setDatasource would increase the refct. Well, it apparently doesn’t.

Is there any way I can change this behavior?

Note: Everything works if I create an ivar and store the data source, but I feel like that clutters my class. Is this just life in the city?

  • 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-10T00:06:51+00:00Added an answer on June 10, 2026 at 12:06 am

    From the documentation of UITableView:

    @property(nonatomic, assign) id dataSource

    Discussion

    The data source must adopt the UITableViewDataSource protocol. The data source is not retained.

    This means that customerTableView expects you to retain your data source object, which you did not do. Same goes for UITableView‘s delegate (in fact, for almost any delegate in cocoa, except CALayer‘s one). This design decision is made for a reason: the object that holds on to UITableView very often also serves as its delegate. Had the delegate been retained, the programmers would have to deal with retain cycles.

    Unfortunately, the consequence of that decision is the problem that you are having: now you need to retain the data source (and the delegate, if any), e.g. by setting up an ivar.

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

Sidebar

Related Questions

I have a UIViewController named RootViewController which contains a UITableView and a UITabBar (2
I have a UIViewController (which sits inside a tabUIController). Within this UIViewController, I want
I have a root UIViewController which has a property called webView. WebView is a
I have BaseView which implement UIViewController. Every view in project must implement this BaseView.
I have a view controller which contains a UISearchBar @interface TradeFindHeaderViewController_iPhone : UIViewController {
I have a view which contains a tableview, (i call this view the EquationView,
I have a UIViewController which contains a UIWebView . i login to a website
I have a very simple scenario: My iPhone application contains a UIViewController implementation which
First a little background info: I have UIViewController that contains a UITableView. In the
Inside Interface Builder I have a UINavigationController, which contains a UIViewController, which has a

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.