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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:15:33+00:00 2026-05-28T16:15:33+00:00

I create tableView with my custom cells. here the code of the cell .h

  • 0

I create tableView with my custom cells.
here the code of the cell .h file

@interface ZUITableViewCell : UITableViewCell {
    IBOutlet UITextField *_textFieldOutlet;
    IBOutlet UILabel *_textLabelOutlet;

}
@property (retain, nonatomic) IBOutlet UITextField *_textFieldOutlet;
@property (retain, nonatomic) IBOutlet UILabel *_textLabelOutlet;

@end

And in my tableview controller file I create this

#import <UIKit/UIKit.h>
#import "ZUITableViewCell.h"

@protocol ZUITableViewControllerDelegate  ///for main view controller

-(void) doneButtonPressed;

@end

@interface ZUITableViewController : UITableViewController {
    id <ZUITableViewControllerDelegate> delegate;

    NSMutableArray *menuItems;
    BOOL isAddingFields;
}

@property (nonatomic, retain) NSArray *menuItems;
@property (nonatomic, assign) id<ZUITableViewControllerDelegate> delegate;

- (CGRect) GetCellHegiht: (ZUITableViewCell *) cell;

@end

I want to add new rows in my table view when user select the second row.
To make this I describe this method

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Navigation logic may go here. Create and push another view controller.
    /*
     <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
     // ...
     // Pass the selected object to the new view controller.
     [self.navigationController pushViewController:detailViewController animated:YES];
     [detailViewController release];
     */
    NSLog (@"row = %d", indexPath.row);
    NSLog(@"INIT %p", self);
    ZUITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    [cell._textFieldOutlet becomeFirstResponder];
     if (indexPath.row == 1 && isAddingFields == FALSE) {
         isAddingFields = TRUE;
         [menuItems insertObject:@"CC" atIndex:1];
         [menuItems insertObject:@"BCC" atIndex:2];

         NSIndexPath *path1 = [NSIndexPath indexPathForRow:1 inSection:0];
         NSIndexPath *path2 = [NSIndexPath indexPathForRow:2 inSection:0];
         NSArray *indexArray = [NSArray arrayWithObjects:path1,path2,nil];
         [tableView insertRowsAtIndexPaths:indexArray withRowAnimation:UITableViewRowAnimationTop];
         [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];

         [path1 release];
         [path2 release];

         [cell._textFieldOutlet becomeFirstResponder];
     }
}

and there is my cellForRowAtIndexPath method

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    NSLog(@"INIT %p", self);
    NSLog (@"cell for row = %d", indexPath.row);
    ZUITableViewCell *cell = (ZUITableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        NSArray *topLevelsObjects = [[NSBundle mainBundle] loadNibNamed:@"ZUITableViewCell" owner:nil options:nil];
        for (id currentObject in topLevelsObjects){
            if ([currentObject  isKindOfClass:[UITableViewCell class]]){
                cell = (ZUITableViewCell *) currentObject;
                break;
            }
        }
    }
    if (indexPath.row == 3 && isAddingFields == FALSE){
       // [cell setBounds:[self GetCellHegiht:cell]];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell._textLabelOutlet.text = [menuItems objectAtIndex:indexPath.row];
    cell._textFieldOutlet.tag = indexPath.row;
    [cell._textFieldOutlet setEnabled:YES];
    if(indexPath.row == 0){
        [cell._textFieldOutlet becomeFirstResponder];
    }


    return cell;
}

In debug mode as I can see after clicking to the row with indexPath.row == 1 this controller call method cellForRowAtIndexPath two times with indexPath.row = 1 and 2. But After It controller call method

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
//#warning Incomplete method implementation.
    return [menuItems count];
}

again and method cellForRowAtIndexPath calling too, After program take me this error (I enable zombie) Error -[NSIndexPath release]: message sent to deallocated instance 0x6a9d790

  • 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-28T16:15:34+00:00Added an answer on May 28, 2026 at 4:15 pm

    The method [NSIndexPath indexPathForRow:inSection:] (used in path1 and path2) returns an autoreleased object, no need to call release after.

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

Sidebar

Related Questions

I've got a problem trying to create a custom tableview cell for my iPhone
I'm reading a custom table cell in tableView:cellForRowAtIndexPath: from a nib file. This works
I have a custom UITableViewCell that I use like this: AppTableCell *cell = [tableView
I have a tableView with custom cells in it, each cell has a UISlider
I have a custom cell which has two UILabel objects. //AppEventCell.h #import <UIKit/UIKit.h> @interface
I have 5 cells in a tableview that are all custom. Meaning, I've created
I am re-using Apple's AdvancedTableViewCells example to create a custom, fast-scrolling tableview. Specifically, I
I have a custom UITableViewCell which I created in Interface Builder. I am successfully
I want to give custom cell's UIButton IBAction event. I tried with below code
I'm having some trouble here. I've got a tableview, with 7 cells, all of

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.