Note that there are some explanatory texts on larger screens.

plurals
  1. POWait on main thread until an asynchronous process is completed?
    primarykey
    data
    text
    <p>I am using a proxy which is making asynchronous network calls. The response is to be processed and passed as an argument to the method in the next line. The code illustration is below:</p> <pre><code>- (MyClass *) performOperations{ ... ... [self callProxyMethodsTarget:self action:@selector(receivedValue:) withObject:anObject]; //making an asynchronous call here return response; } - (void) receivedValue:(id)response{ ///need this return value from network call to return from performOperartions ... ... } </code></pre> <p>My problem is that as the proxy methods are making asynchronous network calls, I am not able to get the response in time to return it.</p> <p>I have thought of many things, like:</p> <ul> <li>making the network calls synchronous but that would require a lot of rework and may introduce unforeseen issues</li> <li>changing the return type and pass the response from receivedValue, but can't do that as my client has defined these method names and return types and on other platforms the team is using synchronous calls</li> </ul> <p>I have thought of a solution like:</p> <pre><code> - (MyClass *) performOperations{ ... ... [self callProxyMethodsTarget:self action:@selector(receivedValue:) withObject:anObject]; //making an asynchronous call here ///write a code here to wait until response is received return response; } - (void) receivedValue:(id)response{ ///need this return value from network call to return from performOperartions ... ... } </code></pre> <p>But have failed to do so.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload