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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:42:04+00:00 2026-05-26T02:42:04+00:00

I’ve been trying to figure this out for 2 days now, and before anyone

  • 0

I’ve been trying to figure this out for 2 days now, and before anyone posts another stackoverflow question, I’ve read them all and none of them cover my problem exactly:

I have a CoreData app that updates dynamically. Now during the update I want an UIAlertView to pop up saying that an update is being downloaded.

So here’s the important code:

AppDelegate:

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    [myUpdater checkForUpdatesInContext:self.managedObjectContext];    
}

_

Updater Class:

- (void)checkForUpdatesInContext:(NSManagedObjectContext *)myManagedObjectContext
{
    [self loadUpdateTime];
    NSLog(@"Update start");
    NSDate *now = [NSDate dateWithTimeIntervalSinceNow:[[NSTimeZone localTimeZone] secondsFromGMT]];
    if ([now timeIntervalSinceDate:updateTime] < UPDATE_TIME_INTERVAL)
    {
        return;
    }
    [self showAlertViewWithTitle:@"Update"];
    ... //updating process
    [self.alertView dismissWithClickedButtonIndex:0 animated:YES];
    NSLog (@"Update done");
}

- (void) showAlertViewWithTitle:(NSString *)title
{
    self.alertView = [[UIAlertView alloc] initWithTitle:title message:@"Daten werden aktualisiert..." delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
    ... //design the alertView
    [self.alertView show];
    NSLog (@"AlertView shows");
}

So here is what happens when I run this:

  1. Launch image shows
  2. NSLog “Update starts” fires
  3. NSLog “AlertView shows” fires
  4. Screen dims but no AlertView is shown
  5. Update is running
  6. NSLog “Update done” fires
  7. Launch image goes away and TabBarController shows up
  8. UIAlertView shows up and is dismissed right away and the dimmed screen returns to normal

What I would like to have happen:

  1. Launch image
  2. TabBarController shows up
  3. Screen dims and UIAlertView shows
  4. Update is running
  5. UIAlertView gets dismissed and dimmed screen returns to normal

I know it’s something with the UI Thread and the main Thread and stuff.. But I tried every combination it seems but still not the expected result. Please help 🙂

EDIT:

HighlightsViewController Class:

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.updater = [[Updater alloc] init];
    [updater checkForUpdatesInContext:self.managedObjectContext];

    ... // other setup stuff nothing worth mentioning
}

Is this the right place to call [super viewDidLoad]? Because it still doesn’t work like this, still the update is being done while the Launch Image is showing on the screen. :-(( I’m about to give this one up..

  • 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-26T02:42:04+00:00Added an answer on May 26, 2026 at 2:42 am

    Here you go, in this prototype things work exactly how you want them to.

    Header:

    #import <UIKit/UIKit.h>
    
    @interface AlertViewProtoViewController : UIViewController
    {
    
    }
    
    - (void) showAlertViewWithTitle:(NSString *)title;
    - (void) checkForUpdatesInContext;
    - (void) update;
    - (void)someMethod;
    - (void)someOtherMethod;
    
    @end
    
    #import "AlertViewProtoViewController.h"
    

    Class:

    @implementation AlertViewProtoViewController
    
    UIAlertView *alertView;
    bool updateDone;
    UILabel *test;
    bool timershizzle;
    
    #pragma mark - View lifecycle
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
    
        self.view.backgroundColor = [UIColor yellowColor];
    
        UILabel *test = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 500, 500)];
        test.backgroundColor = [UIColor blueColor];
        [self.view addSubview:test];
    
        [self performSelector:@selector(checkForUpdatesInContext) withObject:nil afterDelay:0.0];
    }
    
    
    - (void)update
    {
        //NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; //commented for auto ref counting
        NSLog(@"update start");
        //your update stuff
        NSLog(@"update end");
        updateDone = YES;
        //[pool release];
    }
    
    - (void)checkForUpdatesInContext//:(NSManagedObjectContext *)myManagedObjectContext
    {
        //[self loadUpdateTime];
    
        NSLog(@"Update start");
    
        NSDate *now = [NSDate dateWithTimeIntervalSinceNow:[[NSTimeZone localTimeZone] secondsFromGMT]];
        //    if ([now timeIntervalSinceDate:updateTime] < UPDATE_TIME_INTERVAL)
        //    {
        //        return;
        //    }
        [self showAlertViewWithTitle:@"Update"];
        //[self setManagedObjectContext:myManagedObjectContext];
    
        [self performSelector:@selector(someMethod) withObject:nil afterDelay:0.0];
    
        [self performSelector:@selector(someOtherMethod) withObject:nil afterDelay:0.0];
    }
    
    -(void)someOtherMethod
    {
        while (!updateDone) {
            //        NSLog(@"waiting...");
        }
    
        [alertView dismissWithClickedButtonIndex:0 animated:YES];
        NSLog (@"Update done");
        self.view.backgroundColor = [UIColor greenColor];
    }
    
    -(void)someMethod
    {
        [self performSelectorInBackground:@selector(update) withObject:nil];
    }
    
    - (void) showAlertViewWithTitle:(NSString *)title
    {
        alertView = [[UIAlertView alloc] initWithTitle:title message:@"Daten werden aktualisiert..." delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
        alertView.frame = CGRectMake(100, 100, 200, 200);
        alertView.backgroundColor = [UIColor whiteColor];
    
        [self.view addSubview:alertView];
    
        [self.view setNeedsDisplay];
    
        NSLog (@"AlertView shows");
    }
    
    @end
    

    You should adjust were needed for your own purposes but it works.

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
This could be a duplicate question, but I have no idea what search terms
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text

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.