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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:41:41+00:00 2026-05-26T18:41:41+00:00

I want to enable an UIAlertView-Request before the user can delete an item from

  • 0

I want to enable an UIAlertView-Request before the user can delete an item from my tableview. But the indexPath seems to be “nil”…

That is my coding:

The header-file looks like that ..

    @interface ReturnRootViewController : UITableViewController <NSFetchedResultsControllerDelegate> {
    // ..
        NSIndexPath                 *deleteSelectedRow;     
    }

    // ..
    @property (nonatomic, retain) NSIndexPath                   *deleteSelectedRow;

    @end

.. the implemtation file looks like that ..

    - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

    if (editingStyle == UITableViewCellEditingStyleDelete) {
        NSUserDefaults *setting = [NSUserDefaults standardUserDefaults];
        [setting synchronize];

        // for the UIAlert-View handling:
        deleteSelectedRow = indexPath;

        if ([setting boolForKey:@"delete_preference"]) {

            // Sicherheitsabfrage vor dem Löschen
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Achtung", @" ")
                                                            message:NSLocalizedString(@"Sind Sie sicher, dass Sie den Eintrag löschen wollen?", @" ")
                                                           delegate:self
                                                  cancelButtonTitle:NSLocalizedString(@"Nein", @"Nein")
                                                  otherButtonTitles:NSLocalizedString(@"Ja", @"Ja"), nil];
            [alert show];
            [alert release];


        } else {
          // just the case you override the settings
            [moc deleteObject:[fetchedResultsController objectAtIndexPath:deleteSelectedRow]];

            NSError *error = nil;
            if (![moc save:&error]) {
                NSLog(@"Ungelöstes Problem %@, %@", error, [error userInfo]);
                abort();
            }
        }

    }   
}

and last but not least the method for the uialertview-handling:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if (buttonIndex == 1) {

        // Delete request
        [moc deleteObject:[fetchedResultsController objectAtIndexPath:deleteSelectedRow]];
// ..

and that is the place where my app dumps! deleteSelectedRow is nil.
by the way: deleteSelectedRow is not nil in the else-Statement from the tableview:commitEditingStyle-method! I’m fully helpless.

Before iOS 5 it works like that …

Thanks for any hints.
ifeelhorst

  • 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-26T18:41:41+00:00Added an answer on May 26, 2026 at 6:41 pm

    As it is now, indexPath could be released by the time the alert view is clicked/returns. Change

    deleteSelectedRow = indexPath;
    

    to

    self.deleteSelectedRow = indexPath; // to retain it
    

    or (to make a copy of it)

    self.deleteSelectedRow = [[indexPath copy] autorelease]; 
    

    This does not explain why it is nil however, try putting a breakpoint on that line and on the alert view clickedButtonAtIndex callback to see what happens.

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

Sidebar

Related Questions

I want to enable the user to select a video file from the on-device
I want enable user to select a photo from a photo library on his
I want to enable an user to be able to communicate with other users
I want to enable the users of my website to download the files from
I want to enable GZIP compression on my gSOAP client. How can I do
i want to disable right click on the webpage but i want enable right
I want to enable Encode::HanExtra on Windows XP environment. I can't find the name
I want to enable Access for assistive devices in System Preferences programmatically. But Problem
I want to enable drag and drop from our windows forms based application to
I want to enable an effect on my web app where a user clicks

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.