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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:31:31+00:00 2026-06-14T20:31:31+00:00

I am creating the cell programatically using the reuse identifier. Note – I am

  • 0

I am creating the cell programatically using the reuse identifier.

Note – I am not using storyboard for creating the cell

Whenever the cell is dequeued, the cell is nil, so the cell needs to be newly created using alloc, which is expensive.

EDIT (added 1 more question and corrected code)

Question

  • Why does this dequeue always return nil ? How can I correct it ?
  • Does dequeue work only when used along with storyboard / nib file ?

Code

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if(!cell) //Every time cell is nil, dequeue not working 
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

    }

    return cell;
}
  • 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-14T20:31:32+00:00Added an answer on June 14, 2026 at 8:31 pm

    I was making a couple of mistakes:

    1. I was using a subclass of UITableViewController, but was creating the tableView outside of the subclass
    2. There is a tableView created in the table view controller, which is self.tableView In the tableview controller while returning the cell for index path, I was using self.tableView instead of tableView.
    3. Also, ensure that the cell identifier is declared as static

      static NSString *CellIdentifier = @"Cell";
      
      UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
      

    Since tableView and self.tableView were representing different tables, the cell was not being dequeued from the same table and hence was always nil

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

Sidebar

Related Questions

I am creating custom cell contain UILabel , UIImageView ,using constant tag for UILabel
Suppose I am creating a UITableViewCell subclass. The cell will not know what its
I am creating custom cell in my iphone aap and I am also adding
I'm creating a custom cell setup. My issue is when I add a subview
Creating a simple RPG game, first time using XNA. Trying to get my character
I'm using the OpenXML SDK to programatically replace some <w:sdt/> elements with chunks of
i am creating a UITableview cell in the following way const NSInteger TOP_LABEL_TAG =
I'm using a UIImageView as the accessoryView in a UITableViewCell that I'm creating programmatically.
I've got some (I think) pretty basic code for creating cell content from a
I'm creating a cell editor, but I've done (and seen) this in other code.

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.