title: Show an AlertView, do parsing and dismiss AlertView - with GCD
body: <p>I m very new to iOS, as stated in the question above; im trying to do these 3 simple step.</p>
  
  <ol>
  <li>Show Alert view</li>
  <li>Do parsing stuff</li>
  <li>Dismiss Alert</li>
  </ol>
  
  <p>I was looking for something like we have in android i.e Pre Execute, doInBackground and Post Execute().</p>
  
  <p>This is what i have tried.</p>
  
  <pre><code>parserAlert = [[UIAlertView alloc] initWithTitle:@"Loading" message:@"Please Wait"    delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
  
  [parserAlert show];
  
  dispatch_queue_t queue = dispatch_queue_create("com.abc.testing",  DISPATCH_QUEUE_SERIAL);
  
  dispatch_sync(queue,^{
     DBHandler *myDB= [[DBHandler alloc] init];
     [myDB fetchResults];
         dispatch_async(dispatch_get_main_queue(),^{
           [parserAlert dismissWithClickedButtonIndex:0 animated:YES];
  
     });
  
  });
  </code></pre>
  
  <p>Below is the fetchResult method.</p>
  
  <pre><code>- (void) fetchResults
  {
  
   IParser *i = [[IParser alloc] init];
   [i startParse];
  
  
   AGParser *ag = [[AGParser alloc] init];
   [ag startParse];
  
  
   GParser *g = [[GParser alloc] init];
   [g startParse];
  
   HParser *h = [[HParser alloc] init];
   [h startParse];
  
   SParser *s = [[SParser alloc] init];
   [s startParse];
  
  
  }
  </code></pre>
  
  <p>This is startParse.</p>
  
  <pre><code>NSString *url = @"http://abcd.com/Service_URL/Service.asmx/GetNotes";
  
  NSURL *nsUrl = [[NSURL alloc] initWithString:url];
  NSURLRequest *request = [[NSURLRequest alloc] initWithURL:nsUrl];
  
  NSURLConnection *con = [[NSURLConnection alloc] initWithRequest:request delegate:self];
  
  responseData = [[NSMutableData alloc] init];
  
  [con start];
  </code></pre>
  
  <p>When i run the above code, Alerview show and dismiss within a second. Adding logs on methods i observed that fetchresults method return immediately and alert view gets dismiss. However fetchResults associated threads(Connection methods, Parser methods) keep executing but alerview is dismissed.</p>
  
  <p>I need a guideline how to block the code until all associated methods are finished. </p>
  
  <p>Thanks for your time.</p>