title: how to change my synchronous to asynchronous call in Objective-C?
body: <p>hi friend i am beginner for objective-c.i have slow response from server side due to synchronous call. i analysed in google the call may be asynchronous means the response speed will be high, but i don't know much about <code>NSURLConnection</code> and <code>GCD</code>. so please help me how to change my call asynchronous . see my code below`</p>
  
  <pre><code>- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { 
  
  NSString* oldToken = [self deviceToken];
  
  NSString *newToken = [[[[deviceToken description]stringByReplacingOccurrencesOfString:@"&lt;"withString:@""]
                                              stringByReplacingOccurrencesOfString:@"&gt;" withString:@""]
                                              stringByReplacingOccurrencesOfString: @" " withString: @""];
  NSLog(@"My token is: %@", newToken);
  
  [self setDeviceToken:newToken];
  
  if (![newToken isEqualToString:oldToken])
  {
      [self calur:newToken];
  }
      }
  
   - (NSString*)deviceToken{
  return [[NSUserDefaults standardUserDefaults] stringForKey:@"deviceid"];
     }
  
   - (void)setDeviceToken:(NSString*)token{
  [[NSUserDefaults standardUserDefaults] setObject:token forKey:@"deviceid"];
      }
  
  
    //This function used to store a notification device id to our notification databae
      -(void)calur:(NSString *)device
    {
  NSString *post =[NSString stringWithFormat:@"deviceId=%@",device];
  NSString *hostStr = @"https://myserver.com/Ver_2_0/notification/check.php?";
  NSError *error = nil;
  
  NSString *nocon=[NSString stringWithContentsOfURL:[NSURL URLWithString:hostStr]encoding:NSUTF8StringEncoding error:&amp;error];
  if (nocon == nil) 
  {
      NSLog(@"NO Connection");
  }
  else 
  {
      hostStr = [hostStr stringByAppendingString:post];
      NSData *dataURL =  [NSData dataWithContentsOfURL: [ NSURL URLWithString: hostStr ]];    
      NSString *serverOutput = [[NSString alloc] initWithData:dataURL encoding: NSASCIIStringEncoding];
  
  
      NSLog(@"hostStr=%@",hostStr);
      NSLog(@"serverOutput = %@",serverOutput);
      NSLog(@"dataURL=%@",dataURL);
     // NSData *dataurl=dataURL;
  
      if([serverOutput isEqualToString:@"Token Updated Successfully"])
      {
          NSLog(@"badge updated");
      }
  
      else 
      {       
          NSLog(@"serverOutput = %@",serverOutput);
  
          NSLog(@"not registered");
      }
      [serverOutput release];
  }
    }`
  </code></pre>