Note that there are some explanatory texts on larger screens.

plurals
  1. POremoveObjectAtIndex crashing the app
    primarykey
    data
    text
    <p>In the .h file I have set the below line.</p> <pre><code> NSMutableArray *repArray; </code></pre> <p>In the .m file I have placed the below lines.(I put just the required lines of code for this ex) -(void)read_data_fromDB { objectsForCharacters = [[NSMutableDictionary alloc]init];</p> <pre><code>sqlite3 *db = [contactAppDelegate getNewDBConnection]; NSMutableString *query = nil; query = [NSMutableString stringWithFormat:@"select representative, title, business_name, uid from corporate where profiler_type &lt;&gt; 'OWN_CORPORATE' order by representative asc"]; const char *sql = [query UTF8String]; sqlite3_stmt *selectAllStmt = nil; if(sqlite3_prepare_v2(db,sql, -1, &amp;selectAllStmt, NULL)!= SQLITE_OK) NSAssert1(0,@"error preparing statement",sqlite3_errmsg(db)); else { repArray = [[NSMutableArray alloc]init]; businessArray = [[NSMutableArray alloc]init]; titleArray = [[NSMutableArray alloc]init]; uidArray = [[NSMutableArray alloc]init]; while(sqlite3_step(selectAllStmt)==SQLITE_ROW) { char *chrstr =(char *)sqlite3_column_text(selectAllStmt, 0); if(chrstr !=NULL) { corpRepresentative = [NSString stringWithUTF8String:chrstr]; [repArray addObject:corpRepresentative]; } chrstr =(char *)sqlite3_column_text(selectAllStmt, 1); if(chrstr !=NULL) { corpTitle = [NSString stringWithUTF8String:chrstr]; [titleArray addObject:corpTitle]; } chrstr =(char *)sqlite3_column_text(selectAllStmt, 2); if(chrstr !=NULL) { corpBusiness_name = [NSString stringWithUTF8String:chrstr]; [businessArray addObject:corpBusiness_name]; } chrstr =(char *)sqlite3_column_text(selectAllStmt, 3); if(chrstr !=NULL) { corporteUid = [NSString stringWithUTF8String:chrstr]; [uidArray addObject:corporteUid]; } } } sqlite3_finalize(selectAllStmt); sqlite3_close(db); </code></pre> <p>}</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; UILongPressGestureRecognizer *longPressGesture = [[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)] autorelease]; [cell addGestureRecognizer:longPressGesture]; } // Configure the cell... UILabel *txtLbl = [[UILabel alloc]initWithFrame:CGRectMake(70, 0, 175, 26)]; //[txtLbl setBackgroundColor:[UIColor greenColor]]; [txtLbl setTextAlignment:UITextAlignmentLeft]; NSString *txtStr = [repArray objectAtIndex:indexPath.row]; UIFont *fontTxtLbl = [UIFont fontWithName: @"FuturaMdBT" size:16]; [txtLbl setFont:fontTxtLbl]; [txtLbl setText:txtStr]; [cell.contentView addSubview:txtLbl]; [txtLbl release]; UILabel *txtDetailLbl = [[UILabel alloc]initWithFrame:CGRectMake(70, 27, 175, 20)]; // [txtDetailLbl setBackgroundColor:[UIColor redColor]]; [txtDetailLbl setTextAlignment:UITextAlignmentLeft]; NSString *txtDetailStr = [titleArray objectAtIndex:indexPath.row]; UIFont *fontTxtDetailLbl = [UIFont fontWithName: @"Arial" size:12]; [txtDetailLbl setFont:fontTxtDetailLbl]; [txtDetailLbl setText:txtDetailStr]; [cell.contentView addSubview:txtDetailLbl]; [txtDetailLbl release]; UILabel *txtDetailLbl1 = [[UILabel alloc]initWithFrame:CGRectMake(70, 47, 175, 20)]; //[txtDetailLbl1 setBackgroundColor:[UIColor blueColor]]; [txtDetailLbl1 setTextAlignment:UITextAlignmentLeft]; NSString *txtDetailStr1 = [businessArray objectAtIndex:indexPath.row]; UIFont *fontTxtDetailLbl1 = [UIFont fontWithName: @"Arial" size:12]; [txtDetailLbl1 setFont:fontTxtDetailLbl1]; [txtDetailLbl1 setText:txtDetailStr1]; [cell.contentView addSubview:txtDetailLbl1]; [txtDetailLbl1 release]; // cell.textLabel.text = [repArray objectAtIndex:indexPath.row]; //cell.detailTextLabel.text = [titleArray objectAtIndex:indexPath.row]; cell.imageView.image=[imagearray objectAtIndex:indexPath.row]; UIView *viewSelected = [[[UIView alloc] init] autorelease]; viewSelected.backgroundColor = [UIColor colorWithRed:224.0/255.0 green:229.0/255.0 blue:241.0/255.0 alpha:1.0]; cell.selectedBackgroundView = viewSelected; cell.textLabel.highlightedTextColor=[UIColor colorWithRed:46.0/255.0 green:77.0/255.0 blue:141.0/255.0 alpha:1.0]; return cell; </code></pre> <p>} </p> <pre><code>-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSString *tempUID = [uidArray objectAtIndex:indexPath.row]; NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; [prefs setObject:tempUCID forKey:@"corpUcid"]; [prefs setObject:@"PROFILER" forKey:@"selProfiler"]; CorpPrevFront *corpPrevFront = [[CorpPrevFront alloc]initWithNibName:@"CorpPrevFront" bundle:nil]; [self.navigationController pushViewController:corpPrevFront animated:NO]; [corpPrevFront release]; [tableView deselectRowAtIndexPath:indexPath animated:NO]; } - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ //FOR VIEW if (buttonIndex == 1 &amp;&amp; [alertView tag] == 1) { // IT WILL BE MATCH ON CorpPrevFront CLASS } //FOR DELETE if(buttonIndex == 2 &amp;&amp; [alertView tag] == 1){ } else if(buttonIndex == 1 &amp;&amp; [alertView tag] == 2){ DeleteProfiler *delProfiler = [[DeleteProfiler alloc]init]; BOOL del = [delProfiler deleteProfiler:selectedCpUid]; //[delProfiler deleteProfiler:selectedCpUcid]; if (del == YES) { [repArray removeObjectAtIndex:selectedIndexPath.section]; [businessArray removeObjectAtIndex:selectedIndexPath.row]; [titleArray removeObjectAtIndex:selectedIndexPath.row]; [ucidArray removeObjectAtIndex:selectedIndexPath.row]; [self.corporateTable reloadData]; } } } </code></pre> <p>I am trying to delete an array element from a method. If I execute the below line then the app crashes automatically in my iPod Touch. But it works fine in simulator without any errors.</p> <pre><code>[repArray removeObjectAtIndex:selectedIndexPath.row]; </code></pre> <p>or</p> <pre><code>[repArray removeObjectAtIndex:0]; </code></pre> <p>both crashes the app even if I have more than one elements in array.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload