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

The Archive Base Latest Questions

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

On a button click, I am calling a web service and after that I

  • 0

On a button click, I am calling a web service and after that I am pushing a UIViewController. My UIViewController should load with the data obtained from the web service. But currently, before my web service is called, the UIViewController is being pushed. What can I do to make sure that my UIViewController is not loaded before all the web service calls are made and data retrieved.

Here is the code I am using.

 MyWebService *webservice = [MyWebService myWebService];
webservice.delegate = self;
[webservice getMyDataWithMyNumber:mySharedNumber myOldNumber:temp];
[webservice getvDetailsWithmyData:myData myNumber:myNumber];

MyViewController *myViewController = [[MyViewController alloc]initWithNibName:@"MyViewController" bundle:nil];
[self.navigationController pushViewController: myViewController animated:YES];
[myViewController release];

Edit: The UIViewController should be pushed only after both web services are called.
I am passing an array to the new UIViewController. The array objects are added during the web service call. I cant figure out a way to do this. Need help. Thanks.

  • 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-31T15:01:30+00:00Added an answer on May 31, 2026 at 3:01 pm

    Your web service needs to call back to the view controller when it has completed.

    This is usually done using a Delegate pattern, but there are other techniques you could use.

    Your first view controller would pass itself as a delegate to MyWebService. MyWebService does what it needs to do, and when it is done it calls a method on its delegate, the view controller.

    In this callback method, you could then push the next view controller.

    You should also consider the user experience with this. A user want’s a responsive device, or at least some indication something is happening. So when calling the web service, show a loading indicator. Alternatively, push the next view controller immediately, and then call the web service from the next view controllers viewWillAppear method (again show some sort of loading feedback).

    .. I just re-read and noticed there is more to it. You have multiple separate web service calls. Are those 2 always called together? You could use a bool flag on return of each one, and only push if both have returned. I’d rather push the new view controller straight away, load them both and let them return independently to the new view controller.

    UPDATED WITH EXAMPLE

    - (void) viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated]
        MyWebService *webservice = [MyWebService myWebService];
        webservice.delegate = self;
        [webservice getMyDataWithMyNumber:mySharedNumber myOldNumber:temp];
        [webservice getvDetailsWithmyData:myData SmartJoinderNumber:myNumber];
        //assume internally these web service calls aggregate into one response
    }
    
    - (void) myWebService:(MyWebService *)webService didRespondWith:(NSData *)data {
        MyViewController *myViewController = [[MyViewController alloc]initWithNibName:@"MyViewController" bundle:nil];
        [self.navigationController pushViewController: myViewController animated:YES];
        [myViewController release];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am calling a function in my controller from a button click .... I
I have a button click event that takes information from controls and enters it
I'm having a big problem when calling a web service from my WPF application.
I'm calling the following method from a button click event to export a datatable
In a web page button click event we need to export 2,00,000 to 5,00,000
I am working on an Android code that on click of a button inserts
I'm calling an dialog from code behind and i've an asp:button. Now i'm trying
I have 3 different validation groups on my web page, but when I click
I'm using WatiN to parse my web site. I have a button that starts
I want to edit UITableView by calling EditTable method on a button click of

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.