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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:11:02+00:00 2026-05-28T20:11:02+00:00

I looked at the TableViewUpdates/TVAnimationGestures from Apple’s WWDC 2010 code and am having trouble

  • 0

I looked at the TableViewUpdates/TVAnimationGestures from Apple’s WWDC 2010 code and am having trouble duplicating a UITableViewCell subclass. This is what I’ve done:

I created a new UITableViewCell subclass with some simple properties:

@interface TargetDetailTableViewCell : UITableViewCell

@property (nonatomic, retain) IBOutlet UILabel *DescriptionLabel;
@property (nonatomic, retain) IBOutlet UILabel *ValueLabel;
@property (nonatomic, retain) IBOutlet UIImageView *DotImageView;

In the .m, I just release memory. In IB, I change my class to TargetDetailTableViewCell for the UITableViewCell I just dragged into IB. I connect the outlets from the TargetDetailTableViewCell to the appropriate labels and image view.

In the class I want to use this:

@class TargetDetailTableViewCell;

//some properties
@property (nonatomic, assign) IBOutlet TargetDetailTableViewCell *TargetCell;

In the .m:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {    
    static NSString *TargetCellIdentifier = @"TargetDetailTableViewCellIdentifier";
    TargetDetailTableViewCell *cell = (TargetDetailTableViewCell *)[tableView dequeueReusableCellWithIdentifier:TargetCellIdentifier];

    if (cell == nil) {
        UINib *nib = [UINib nibWithNibName:@"TargetDetailTableViewCell" bundle:nil];
        [nib instantiateWithOwner:self options:nil];
        cell = self.TargetCell;
        self.TargetCell = nil;
    }
// set some labels
return cell;
}

When I run it, I get the error: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'

The only think I can see that is different between Apple’s example and mine is that when I ctlr-click on the subclass of UITableViewCell in their IB, they have a File’s Owner property set. I have no idea how they connected that outlet as it is declared as a property in the class they use the cell, but there is no physical IB connection they make. Can someone explain that to me or what I am doing wrong?

Also, if anyone can explain this, that would be great:

        UINib *nib = [UINib nibWithNibName:@"TargetDetailTableViewCell" bundle:nil];
        [nib instantiateWithOwner:self options:nil];
        cell = self.TargetCell;
        self.TargetCell = nil;

It seems like you create the nib and the owner of the nib that gets instantiated from memory is the class you are in or self (my viewcontroller). Then the last two lines confuse me. It’s like you tell your cell to point to the newly created object, then you set the newly created object to nil. Which in my head I think, the cell now points to nil as well. Thanks.

  • 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-28T20:11:03+00:00Added an answer on May 28, 2026 at 8:11 pm

    You need to have an owner in your custom table view cell nib and that owner needs to be your TableViewDataSource class (i.e. the table view controller which implements the cellForRowAtIndexPath method and has the TargetCell outlet to the table cell).

    You also need to connect this TargetCell outlet from the file owner (the TableViewController) to your custom table view.

    The reason for this is that when you load the nib, with your table view controller as the owner, it will then set the outlet that you have (the TargetCell property) to point to the table view cell defined in your nib.

    You then copy this reference to the cell method variable, configure it and return it. You assign the property to nil after copying it because you only needed it as a bootstrap to get a reference to the object in the nib for use in the cellForRowAtIndexPath method.

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

Sidebar

Related Questions

I looked at this example from the C# in nutshell book ( http://www.albahari.com/nutshell/ch04.aspx )
I looked into BalusC's code for a custom download servlet from absolute path (see
I looked in the Rails docs under inflector and found this message... Module deprecated
I looked through some code and noticed that the convention was to turn pointer
I looked at this example http://msdn.microsoft.com/en-us/library/bb399420.aspx and clicked on DataContext.CreateDatabase which brought me to
Looked around, couldn't find this specific question discussed. Pretty sure the difference is negligible,
Looked at other posts on SO and they did not solve this issue. I'm
I looked hours to solve this issue, and found nothing. Sorry if answer is
I looked through previous questions to this effect, but my situation is slightly different...
I looked for this in Google and different answers on stackoverflow. And probaly there

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.