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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:08:39+00:00 2026-05-25T14:08:39+00:00

My UITableView is displaying correctly without a hitch. However, it crashes with EXEC_BAD_ACCESS whenever

  • 0

My UITableView is displaying correctly without a hitch. However, it crashes with EXEC_BAD_ACCESS whenever the user tries to scroll down to reveal the bottom rows. I have already tried commenting out every [someobject release] but to no avail. I suspect the culprit is the cellForRowAtIndexPath method. Here is the code for my entire controller :

 -(void)viewDidLoad {

    NSLog(@"myString is :%@", myString);
    int processID = [myString intValue];

    //NSLog(@"transferredArray is %@", transferredArray);
    task = [[NSTask alloc] init];
    [task setLaunchPath: @"/bin/ps"];

    arguments = [NSArray arrayWithObjects: @"aux", [NSString stringWithFormat:@"%i", processID],nil];

    [task setArguments: arguments];

    NSPipe *pipe;
    pipe = [NSPipe pipe];
    [task setStandardOutput:pipe];

    NSFileHandle *file;
    file = [pipe fileHandleForReading];

    [task launch];

    NSData *data;
    data = [file readDataToEndOfFile];

    NSString *string;
    string = [[NSString alloc] initWithData: data
                                   encoding: NSUTF8StringEncoding];

    NSLog(@"ps aux output :%@",string);


    NSArray *lines= [string componentsSeparatedByString:@"\n"];

    NSString *lastline = [lines objectAtIndex:[lines count]-2];
    //  NSLog(@"%@",lastline);



    lines2= [lastline componentsSeparatedByString:@" "];
    NSLog(@"%@",lines2);
    for (int i=0; i<[lines2 count]; i++) {

        if([[lines2 objectAtIndex:i] isEqualToString:@""]){
            [lines2 removeObjectAtIndex:i];
        }

    }


    for (int i=0; i<[lines2 count]; i++) {

        if([[lines2 objectAtIndex:i] isEqualToString:@""]){
            [lines2 removeObjectAtIndex:i];
        }

    }

    for (int i=0; i<[lines2 count]; i++) {

        if([[lines2 objectAtIndex:i] isEqualToString:@""""]){
            [lines2 removeObjectAtIndex:i];
        }

    }

    for (int i=0; i<[lines2 count]; i++) {

        if([[lines2 objectAtIndex:i] isEqualToString:@"0"]){
            [lines2 removeObjectAtIndex:i];
        }

    }

    for (int i=0; i<[lines2 count]; i++) {

        if([[lines2 objectAtIndex:i] isEqualToString:@"0.0"]){
            [lines2 removeObjectAtIndex:i];
        }

    }

    for (int i=0; i<[lines2 count]; i++) {

        if([[lines2 objectAtIndex:i] isEqualToString:@"??"]){
            [lines2 removeObjectAtIndex:i];
        }

    }

    for (int i=0; i<[lines2 count]; i++) {

        if([[lines2 objectAtIndex:i] isEqualToString:@"0:00.00"]){
            [lines2 removeObjectAtIndex:i];
        }

    }

    NSLog(@"lines2 after for loops is %@", lines2);









    NSLog(@"Lines 2 is%@",lines2);



    self.title = @"Process Info";

    label = [[NSMutableArray alloc]init];

    [label addObject:@"User:"];
    [label addObject:@"Process ID:"];
    [label addObject:@"CPU(%):"];
    [label addObject:@"MEM(%):"];
    [label addObject:@"Status:"];
    [label addObject:@"Time Started:"];
    [label addObject:@"Launch Path:"];
    [label addObject:@"STAT:"];
    [label addObject:@"Time Started:"];
    [label addObject:@"Time Elapsed:"];
    [label addObject:@"Launch Command:"];

    [super viewDidLoad];
}


/*
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}
 */


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

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];   


    /*
    NSString *CellIdentifier = [NSString stringWithFromat:@"Cell_%d_%d",indexPath.section,indexPath.row];
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];   
    */
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]autorelease];
    }

    [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; 
    NSString *cellValue = [label objectAtIndex:indexPath.row];
    cell.textLabel.text = cellValue;
    cell.textColor = [UIColor colorWithRed:154.0/255.0 green:14.0/255.0 blue:2.0/255.0 alpha:1];
    cell.font = [UIFont systemFontOfSize:16.0];


    UILabel *label2 =  [[[UILabel alloc] initWithFrame:CGRectMake(120.0, 0, 240.0, 
                                                                  tableView.rowHeight)]autorelease]; 




    label2.font = [UIFont systemFontOfSize:16.0]; 
    NSString *cellValue1 = [lines2 objectAtIndex:indexPath.row];
    label2.text = cellValue1;
    label2.textAlignment = UITextAlignmentLeft; 
    label2.textColor = [UIColor blackColor]; 
    label2.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | 
    UIViewAutoresizingFlexibleHeight; 
    [cell.contentView addSubview:label2]; 


    return cell;
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [lines2 count];
}


- (void)dealloc 
{
    //[transferredArray release];
    //[myString release];
    //[arguments release];
    //[ResultStringID release];
    //[values release];
    //[label release];
    [super dealloc];
}

Any help is very much appreciated! 🙂

  • 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-25T14:08:40+00:00Added an answer on May 25, 2026 at 2:08 pm

    i think this will help:

    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
    
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];   
    
    UILabel *label2;
    if (cell == nil) 
    {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]autorelease];
        [cell setSelectionStyle:UITableViewCellSelectionStyleNone]; 
        cell.textColor = [UIColor colorWithRed:154.0/255.0 green:14.0/255.0 blue:2.0/255.0 alpha:1];
        cell.font = [UIFont systemFontOfSize:16.0];
    
        label2 =  [[[UILabel alloc] initWithFrame:CGRectMake(120.0, 0, 240.0, 
                                                             tableView.rowHeight)]autorelease];
    
        label2.font = [UIFont systemFontOfSize:16.0]; 
        NSString *cellValue1 = [lines2 objectAtIndex:indexPath.row];
        label2.text = cellValue1;
        label2.textAlignment = UITextAlignmentLeft; 
        label2.textColor = [UIColor blackColor]; 
        label2.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | 
        UIViewAutoresizingFlexibleHeight; 
        [cell.contentView addSubview:label2]; 
    
    }
    
    
    NSString *cellValue = [label objectAtIndex:indexPath.row];
    cell.textLabel.text = cellValue;
    
    return cell;
    }
    

    because you tablecell is dequeueble so you shoulden’t init label if cell is not nil. only change text of the label when tableview is updated (or init everything if cell is nil)

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

Sidebar

Related Questions

I am displaying iAd's in the headerView of a UITableView. When the user scrolls
i have two views 1st one is displaying list (uitableview used), user will select
I have a UITableView where I am displaying a list of data. I would
I have a UITableView that can be edited. I am displaying cells as such:
In my application,I will be displaying only one row on the UITableView initially. I
I have a UITableView displaying a list of Cities. I want to separate them
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { // Date formatter for displaying dates static
I would like to completely reset the scroll position of a UITableView, so that
I am disabling a UITableView while displaying a UIActivityIndicatorView, and I just wanted to
I'm trying to setup a UITableView for displaying nested threaded items. I'm using Core

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.