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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:39:04+00:00 2026-05-13T21:39:04+00:00

I have an alertview which displays fine. In my header I’ve included the UIAlertViewDelegate,

  • 0

I have an alertview which displays fine.
In my header I’ve included the UIAlertViewDelegate, but for some reason whenever I click a button on the alert view my app crashes with a bad excess, saying that an unrecognized selector was sent.

Any ideas would be helpful. I have the exact same code running in other classes with no problem at all.

Here’s my code:

    -(void)deletePatient
{
 NSLog(@"Delete");
 //Patient *patientInRow = (Patient *)[[self fetchedResultsController] objectAtIndexPath:cellAtIndexPath];
 NSMutableArray *visitsArray = [[NSMutableArray alloc] initWithArray:[patient.patientsVisits allObjects]];
 //cellAtIndexPath = indexPath;
 int visitsCount = [visitsArray count];
 NSLog(@"Visit count is %i", visitsCount);
 if (visitsCount !=0) 
 {
  //Display AlertView
  NSString *alertString = [NSString stringWithFormat:@"Would you like to delete %@'s data and all their visits and notes?", patient.nameGiven];
  UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:alertString message:nil delegate:self cancelButtonTitle:@"Yes" otherButtonTitles:@"No",nil];
  [alert1 show];
  [alert1 release];

 }
 else if (visitsCount ==0) 
 {
  //Do something else
 }

 [visitsArray release];

}

-(void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
 // the user clicked one of the OK/Cancel buttons
 if (buttonIndex == 0)
 {
  NSLog(@"Yes");

 }
 else
 {
  NSLog(@"No");
 }
}

So the best I can figure it out, its related to the fact I’m calling the deletePatient method from my UITableViewCell subClass, and passing along the patient object as I do so. Here’s the code for passing it along

-(IBAction)deletePatient:(id)sender
{
    NSLog(@"Delete Patient:%@",patient.nameGiven);
    PatientListTableViewController *patientList = [[PatientListTableViewController alloc] init];
    patientList.patient = patient;
    UITableView *tableView = (UITableView *)[self superview];
    tableView.scrollEnabled = YES;
    [patientList deletePatient];
    menuView.center = CGPointMake(160,menuView.center.y);
    [patientList release];
}
  • 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-13T21:39:04+00:00Added an answer on May 13, 2026 at 9:39 pm

    You set patientList object as delegate of UIAlertView instance, then released it. When user clicks alert button it calls [delegate alertView:self clickedButtonAtIndex:buttonIndex], but the delegate, patientList was already released and no longer exists. The variable delegate at this moment contain garbage, so not surprizing it have no alertView:clickedButtonAtIndex: selector;

    Just release patientList object in alert alertView:clickedButtonAtIndex: method, or do patientList creating/releasing when you create/release outer class or simply use property:

    // in *.h file:

    ...
    PatientListTableViewController *patientList;
    ...
    @property(retain) PatientListTableViewController *patientList;
    ...
    

    // in *.m file:
    @synthesize patientList;

    ...
    self.patientList =  [[PatientListTableViewController alloc] init];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Exit application in iOS 4.0 I have a AlertView which displays some
I have crash issue when I click on button of alertView, and i get
I have alertview with button when user click the button the program enter a
I have controller which implements UIAlertViewDelegate. In implementation I have: - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
I have an app which displays in landscape mode and I've overwritten the height
I have created an app which starts with a login page, after entering some
I have a counter in my app that has a reset button, but instead
I have got an alertview which has a text field UIAlertView* dialog = [[UIAlertView
I have a alert sheet which contains a delete button. On tap of delete
i have created an alertview with textfield and the details which is inserted in

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.