problem with UIActivityIndicatorView( spinner)..plz help me

Hi frends,

I am getting problem with UIActivityIndicatorView( spinner).

actually my requirement is when ever i click the button the spinner has to appear on the screen,

here i am using "syn request", it takes few seconds time. that's why i am using spinner there.

but here the spinner is appearing after the response. [it means after few seconds the spinner is appearing]

can any one help me plz ....

for your reference i added my code snippet.


myViewController.h
--------------------------
@interface myViewController : UIViewController {

IBOutlet UIActivityIndicatorView *spinner;

}

@property(nonatomic, retain) IBOutlet UIActivityIndicatorView *spinner;

myViewController.m

@synthesize spinner;

@implementation myViewController

- (IBAction)buttonClicked🙁id)sender
{
[spinner startAnimating];

- - - - - - - - -
- - - - - - - - -
- - - - - - - - -
- - - - - - - - -
NSError *error;
NSURLResponse *response = nil;
NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];

- - - - - - - - -
- - - - - - - - -
- - - - - - - - -
- - - - - - - - -

[spinner startAnimating];

}

Original thread: https://forums.imore.com/threads/problem-with-uiactivityindicatorview-spinner-plz-help-me.185405/