Stefan
Stefan

Reputation: 235

UILabel strange behaviour

i have this:

 - (IBAction)checkupdate
 { 
statusText.text = [[NSString alloc] initWithFormat:@"Checking......"];

everytime i press button, the string get display, ok no problem with that.

now when i add

NSURLRequest *theRequest = 
[NSURLRequest requestWithURL:
 [NSURL URLWithString:@"http:/myserver/version.plist"] 
                 cachePolicy:NSURLRequestUseProtocolCachePolicy
             timeoutInterval:5.0];    
NSURLResponse *response;
NSData *received = 
[NSURLConnection sendSynchronousRequest:theRequest 
                      returningResponse:&response error:&error];   

the string doesn't get display 1st. the NSURLRequest code is below the string display code all within the same action.

the string only display after the nsurlrequest is done.

isn't the displaying of the string suppose to execute 1st? i tried putting { , } to cover up the nsurlrequest, but still it get execute 1st.

any ideas?

Upvotes: 0

Views: 144

Answers (1)

Eric Fortin
Eric Fortin

Reputation: 7603

The value of the label has been set but the redraw of the label can only be done when the function exits and it's not guaranteed to happen right at the exit. Since your making your request synchronously, it can take a long time before it is redrawn.

Upvotes: 1

Related Questions