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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T21:31:50+00:00 2026-05-28T21:31:50+00:00

Currently i’m having trouble using two functions in my -(void)viewDidLoad , both of these

  • 0

Currently i’m having trouble using two functions in my -(void)viewDidLoad, both of these functions uses NSUrlRequest to send HTTPPost to a webservice to recieve data.

It works fine untill [self bar] decides to kick in before [self foo] is completely finished. So, is there any smart way of checking if [self bar] is completely finished before starting [self foo]?

-(void)viewDidLoad{

[self foo]; // initiates a nsxmlparsercall to a webservice to get values.

[self bar]; // relies on the values recieved from [self foo] to make it's own call.

            /* However, [self bar] always crashes before initiating it's request.
            /* It crashes when the variables that are being sent with the poststring 
            /* are being set, as they are null. 
            /* Which means that the `[self foo]` doesnt get completed before starting [self bar];
}

I might be very off at this point, i’ve even considered overriding -(void)viewDidload and setting a bool to control when it’s ok to fire the second function, but that seems like super poor coding..

Any suggestions and/or tips on how to point me in the right direction will be highly appreciated. Thanks in advance.

  • 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-28T21:31:50+00:00Added an answer on May 28, 2026 at 9:31 pm

    I best place to put your function will be one of the delegate methods of nsxmlparser that is

    - (void)parserDidEndDocument:(NSXMLParser *)parser
    {
        [self bar];
    }
    

    This fine if you are parsing the response on a background thread and it doesn’t matter if the function bar is called on main thread or background thread.

    But if you want to call the bar function specifically on main thread then you can use this function

    [self performSelectorOnMainThread:@SEL(bar) withObject:nil waitUntilDone:YES];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I know of only two ways to cache data (I use PHP but
Currently, I am developing a product that does fairly intensive calculations using MS SQL
Currently I using the following code to get my JSON output from MySQL. <?php
Currently I have some legacy ASP.NET 2.0 code that uses the ASP Xml web
Currently, working with RC0 Denali, having some issues I am attempting to review data
Currently I am using a pretty basic function to pre-load images: function preload(arrayOfImages) {
Currently, I'm using && and || instead of AND and OR because that's how
Currently I'm transferring a String across the network, using DataInput/OutputStream's. The String I am
Currently I am using Amazon Cloudfront to service static objects on my ASP.Net MVC3
Currently, I don't really have a good method of debugging JavaScript in Internet Explorer and

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.