Note that there are some explanatory texts on larger screens.

plurals
  1. POwhile loop can't exit without NSLog
    primarykey
    data
    text
    <p>I am trying to create a login page that displays a waiting page while attempting. it has an <code>UIActivityIndicatorView</code> runs on main thread and another thread doing the connection. The code works fine when I uncomment <code>NSLog</code>, but it keeps running when I comment it out. Can anyone explain to me why it doesn't exist the while loop when there is no <code>NSLog</code>? it is a bit complicated. I have a control class that prepare the <code>websocket</code> command and fires it if and only if the <code>websocket</code> is successfully connected. </p> <p>The action flow is like this: </p> <p><code>LoginButton</code> is clicked -> <code>rootView</code> calls <code>[_spinner startAnimating];</code> -> attempting connecting to <code>websocket</code> -> send log in command when successfully connected.</p> <p><code>rootView</code> has to animate the spinner and wait for the response.</p> <pre><code> [_spinner startAnimating]; [NSThread detachNewThreadSelector:@selector(attampingWS) toTarget:self withObject:nil]; - (void) attampingWS { while ([connection isAttamptingWS] &amp;&amp; ![connection isConnectedToWebSocket]) { /** waiting until it's done **/ // NSLog(@"?"); } if ([connection isConnectedToWebSocket]) { [self proceedLogin]; [_spinner performSelectorOnMainThread:@selector(stopAnimating) withObject:nil waitUntilDone:NO]; } } </code></pre> <p>in connection class: </p> <pre><code> @property(nonatomic) NSTimer *attampConnectionTimeOut; @property(nonatomic) NSTimer *attampConnection; @property BOOL isConnectedToWebSocket; - (BOOL) isAttamptingWS { return [_attampConnection isValid]; } - (BOOL) isWaitingForResponse { return [_waitingForResponse isValid]; } /** this method is redirected from websocket by using delegation **/ - (void)dbConnectionDidConnected:(websocket *)connection { [self _terminateAttamptingConnection]; [self setIsConnectedToWebSocket:TRUE]; } </code></pre>
    singulars
    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.
 

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