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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:14:33+00:00 2026-05-24T06:14:33+00:00

In my app I have an advanced search page which uses a tableview with

  • 0

In my app I have an advanced search page which uses a tableview with 4 cells to access 4 tableviews as drop-down fields basically. These are populated from the results of parsing a xml I receive from a url request that happens when the app first loads and is stored in the appDelegate to be accessed by the tableviews later when the advanced search page is accessed. In normal, good internet connection circumstances, this takes a split-second, so the information is there far before the adv. search page could even be accessed, but I want to cover myself in case of a really slow connection.
So, I am putting an alertview with a spinner over the advanced search page if a flag I set is false(the data is still being requested/parsed). I was able to get this to work, and I had the cancel button taking the user back to the previous page in case they didn’t want to wait. But I also need the alert to be dismissed if the flag changes to true(meaning the parsing is done), and that is where I’m starting to have trouble. I’m starting an infinite loop to keep checking if the flag is true, and then dismissing the alert when it breaks out of it. I put it in a separate thread so the loop doesn’t block the user from being able to hit the cancel button, but I’m getting all sorts of runtime errors about:

-[UIAlertView dismissWithClickedButtonIndex:animated:]: message sent
to deallocated instance 0x105330

Here’s the relevant code:

-(void)viewDidAppear:(BOOL)animated
{
    [NSThread detachNewThreadSelector:@selector(waitTilDone) toTarget:self withObject:nil];
}

-(void)waitTilDone{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    while (mainDelegate.artistDone == @"no" || mainDelegate.mediumDone == @"no" || mainDelegate.seriesDone == @"no" || mainDelegate.areaDone == @"no") {
    }
    [av dismissWithClickedButtonIndex:0 animated:YES];
    [pool release];
}

-(void)viewDidLoad 
{    
    mainDelegate = (PublicArtOmahaAppDelegate*)[[UIApplication sharedApplication]delegate];

    if (mainDelegate.artistDone == @"no" || mainDelegate.mediumDone == @"no" || mainDelegate.seriesDone == @"no" || mainDelegate.areaDone == @"no") {
         av=[[UIAlertView alloc] initWithTitle:@"Loading Form Data" message:@"\n" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
        UIActivityIndicatorView *ActInd=[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
        [ActInd startAnimating];
        [ActInd setFrame:CGRectMake(125, 40, 37, 37)];
        [av addSubview:ActInd];
        [av show];
        [av release];
        }
    [super viewDidLoad];
}

- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    // the user clicked on the Cancel button
    [self dismissModalViewControllerAnimated:YES];
}

So my questions are:

  1. Is the infinite loop a crappy way of checking if I can dismiss it? I need to do it somehow… :/

  2. Obviously I’m managing memory poorly here, but I’m pretty new to this so I don’t know what I’m doing wrong. Is there a quick fix there?

  • 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-24T06:14:34+00:00Added an answer on May 24, 2026 at 6:14 am

    For 1): Yes, that is crazy. Use key/value observing (KVO), [NSNotificationCenter defaultCenter], write your own delegate, or something else, to be notified when the value actually changes, instead of polling it.

    For 2): Don’t release it until you’re done with it. Properties can be helpful here, since it simplifies a lot of things.

    // In header
    @property (nonatomic, retain) UIAlertView *av;
    
    // When showing it
    self.av = [[[UIAlertView alloc] initWith....] autorelease];
    ...
    
    // When dismissing it
    [self.av dismiss];
    self.av = nil;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rails app that uses Sunspot and Solr for search functionality. I'm
I'm building an advanced search form for my ASP.NET MVC app. I have a
I have search functionality in my app, in which when user clicks in textbox,
I have my app have a simple TableView, and it was working all day
I have an app on the android market, which I periodically update with new
In my android app I have a search screen. The content is stored in
I have an app in the App Store that uses geofences to post updates
I'm building an web app that uses this code to search for addresses: http://code.google.com/intl/en/apis/maps/documentation/javascript/examples/places-autocomplete.html
I have created a WebView layout, which is used to access a specific website,
I have several applications in App Store and I wish to get further advanced

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.