When creating my UITableViewCells, why is the init never called? (Resulting in blank cells?)

In my UITableView, I recently changed the structure of the cell from formerly just putting UILabels in the contentView of the cell, to adding two UIViews (CellFront and CellBack, on top of one another) into the contentView (so I can achieve a sliding effect by sliding the top one off and revealing the lower one) and adding the UILabels to the top UIView.

However, now, for whatever reason, the cells never get init'd and as a result my UITableView is full of blank cells.

My cell gets created as follows (ArticleCell is a subclass of UITableViewCell):

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    static NSString *CellIdentifier = nil;

    ArticleInfo *articleInfo = [self.fetchedResultsController objectAtIndexPath:indexPath];

    // Checks if user simply added a body of text (not from a source or URL)
    if ([articleInfo.isUserAddedText isEqualToNumber:@(YES)]) {
        CellIdentifier = @"BasicArticleCell";
    else {
        CellIdentifier = @"FullArticleCell";

    ArticleCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    if (cell == nil) {
        cell = [[ArticleCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

    // If the user simply added a body of text, only articlePreview and progress has to be set
    cell.preview = articleInfo.preview;

    // If it's from a URL or a source, set title and URL as well
    if ([articleInfo.isUserAddedText isEqualToNumber:@(NO)]) {
        cell.title = articleInfo.title;
        cell.URL = articleInfo.url;

    return cell;

But I set a breakpoint on the initWithStyle method above within the if statement and it never gets called:

What would cause this? I'm deleting the app and building it from scratch every time, so data is definitely being added to the UITableView, but all the cells are blank. And I can tell a bunch of cells are being added as I have disclosure indicators on all of them, and the table view just gets filled with empty cells with the indicators only.

What am I doing wrong?



ArticleCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

instead of

ArticleCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

the first one is the old standard way. It will not create a cell for you. While with the second a cell will be created form the storyboard. So if you use storyboards you should use indeed the method you are using now, but it will never go info the if branch, as the cell will never be nil.

when instantiating form storyboard, initWithStyle:reuseIdentifier: is never called. Either set everything up in -initWithCoder: or -layoutSubviews

Need Your Help

iphone sdk: pausing NSURLConnection?

iphone nsurlconnection

In my app I give the user the ability to download files from a server. For that I use NSURLConnection. I would like to give the user the ability to pause and resume the download by tapping a button...

use a 512 bit asymmetric encryption key to avoid 'contain encryption' in the app

iphone ios appstore-approval encryption-asymmetric

I have an app that contains a sqlite db with some data is encrypted with a public/private key combination. I generate this pair from the distribution provisional certificate in keychain access (Right

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.