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

  • Home
  • SEARCH
  • 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 842967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:03:02+00:00 2026-05-15T06:03:02+00:00

I need to know how you can find out when all processes (loaded) from

  • 0

I need to know how you can find out when all processes (loaded) from a - (void) are done, if it’s possible.

Why? I’m loading in data for a UITableView, and I need to know when a Loading... view can be replaced with the UITableView, and when I can start creating the cells.

This is my code:

- (void) reloadData {
    NSAutoreleasePool *releasePool = [[NSAutoreleasePool alloc] init];

    NSLog(@"Reloading data.");
    NSURL *urlPosts = [NSURL URLWithString:[NSString stringWithFormat:@"%@", URL]];
    NSError *lookupError = nil;
    NSString *data = [[NSString alloc] initWithContentsOfURL:urlPosts encoding:NSUTF8StringEncoding error:&lookupError];
    postsData = [data componentsSeparatedByString:@"~"];
    [data release], data = nil;
    urlPosts = nil;

    self.numberOfPosts = [[postsData objectAtIndex:0] intValue];
    self.postsArrayID = [[postsData objectAtIndex:1] componentsSeparatedByString:@"#"];
    self.postsArrayDate = [[postsData objectAtIndex:2] componentsSeparatedByString:@"#"];
    self.postsArrayTitle = [[postsData objectAtIndex:3] componentsSeparatedByString:@"#"];
    self.postsArrayComments = [[postsData objectAtIndex:4] componentsSeparatedByString:@"#"];
    self.postsArrayImgSrc = [[postsData objectAtIndex:5] componentsSeparatedByString:@"#"];


    NSMutableArray *writeToPlist = [NSMutableArray array];
    NSMutableArray *writeToNoImagePlist = [NSMutableArray array];
    NSMutableArray *imagesStored = [NSMutableArray arrayWithContentsOfFile:[rootPath stringByAppendingPathComponent:@"imagesStored.plist"]];
    int loop = 0;
    for (NSString *postID in postsArrayID) {
        if ([imagesStored containsObject:[NSString stringWithFormat:@"%@.png", postID]]){
            NSLog(@"Allready stored, jump to next. ID: %@", postID);
            continue;
        }
        NSLog(@"%@.png", postID);

        NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:[postsArrayImgSrc objectAtIndex:loop]]];

        // If image contains anything, set cellImage to image. If image is empty, try one more time or use noImage.png, set in IB
        if (imageData == nil){
            NSLog(@"imageData is empty before trying .jpeg");

            // If image == nil, try to replace .jpg with .jpeg, and if that worked, set cellImage to that image. If that is also nil, use noImage.png, set in IB. 
            imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:[[postsArrayImgSrc objectAtIndex:loop] stringByReplacingOccurrencesOfString:@".jpg" withString:@".jpeg"]]];

        }
        if (imageData != nil){
            NSLog(@"imageData is NOT empty when creating file");
            [fileManager createFileAtPath:[rootPath stringByAppendingPathComponent:[NSString stringWithFormat:@"images/%@.png", postID]] contents:imageData attributes:nil];
            [writeToPlist addObject:[NSString stringWithFormat:@"%@.png", postID]];
        } else {
            [writeToNoImagePlist addObject:[NSString stringWithFormat:@"%@", postID]];

        }
        imageData = nil;

        loop++;

        NSLog(@"imagePlist: %@\nnoImagePlist: %@", writeToPlist, writeToNoImagePlist);
    }
    NSMutableArray *writeToAllPlist = [NSMutableArray arrayWithArray:writeToPlist];

    [writeToPlist addObjectsFromArray:[NSArray arrayWithContentsOfFile:nowPlist]];

    [writeToAllPlist addObjectsFromArray:[NSArray arrayWithContentsOfFile:[rootPath stringByAppendingPathComponent:@"imagesStored.plist"]]];

    [writeToNoImagePlist addObjectsFromArray:[NSArray arrayWithContentsOfFile:[rootPath stringByAppendingPathComponent:@"noImage.plist"]]];

    [writeToPlist writeToFile:nowPlist atomically:YES];
    [writeToAllPlist writeToFile:[rootPath stringByAppendingPathComponent:@"imagesStored.plist"] atomically:YES];
    [writeToNoImagePlist writeToFile:[rootPath stringByAppendingPathComponent:@"noImage.plist"] atomically:YES];
    [releasePool 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-15T06:03:03+00:00Added an answer on May 15, 2026 at 6:03 am

    It is as simple as returning a bool at the bottom of the selector being run in the background, and reaload the UITableView.

    Thanks to @iWasRobbed:

    I have never done this, but just speculating: have you tried returning a BOOL at the very end so that the reloadData function will return TRUE when it gets to that point? I am assuming (possibly incorrectly) that the device serially handles tasks one-at-a-time, so give it a shot.

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

Sidebar

Related Questions

I need to get all events from the current class, and find out the
I need to start a monitor on some machines to find out which processes
I'm working in a C++ unmanaged project. I need to know how can I
I need to know if I can create a file in a specific folder,
I need to know how I can detect the current application pool I am
I need to store a double as a string. I know I can use
I need to generate a list of sequential numbers. I know Ruby you can
Seems so basic, I can't believe I don't know this! I just need a
I need to know how much space occupies all the databases inside an SQL
I have assigned macro to few buttons. How can I find out inside macro

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.