I\'m newbie programming for mac and i\'m really surprised on Grand Central Dispatch. I read about that and looks like the perfect solution for parallel programming. I worked wit
-(void)Search_load_Scraping{
Reachability *reachability = [Reachability reachabilityForInternetConnection];
NetworkStatus internetStatus = [reachability currentReachabilityStatus];
if (internetStatus != NotReachable)
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
^{
TrainInfo *TrnObj=[[TrainInfo alloc]init];
ScrapingClass *scrap=[[ScrapingClass alloc]init];
TrnObj= [scrap train_information: [NSString stringWithFormat:@"http://erail.in/Rail/getPNRStatusAsynch.aspx?Data=%@",pnr_no]];
// NSLog(@"NAME..... %@ NO %@ Date %@ Class %@ \ndes==%@\n %@ \n Dep time %@ Arr time %@ PASSENGER%@ Class %@", TrnObj.TrainName,TrnObj.TrainNumber,TrnObj.TrainDate,TrnObj.TrainBokingSts,TrnObj.TrainBoarding,TrnObj.TrainDestination,TrnObj.TrainDepTime,TrnObj.TrainArrivalTime,TrnObj.trainTicDictionary,TrnObj.TrainClass);
dispatch_sync(dispatch_get_main_queue(), ^{
//If self.image is atomic (not declared with nonatomic)
// you could have set it directly above
[activityIndicator stopAnimating];
if ([TrnObj.TrainNumber length]>3){
//********************** ************************
[dbSingleton() createEditableCopyOfDatabaseIfNeeded];
if ([dbSingleton() checkpnrEsistence:pnr_no]>0)
{
// [dbSingleton() deletePnr:pnr_no];
[dbSingleton() update_Pnr:TrnObj.TrainName trainNumber:TrnObj.TrainNumber chartPrepared:TrnObj.TrainChart className:TrnObj.TrainClass alight_code:TrnObj.TrainDestinationCode alight_name:TrnObj.TrainDestination board_code:TrnObj.TrainBoardingCode board_name:TrnObj.TrainBoarding from_code:TrnObj.TrainDestinationCode from_name:TrnObj.TrainBoarding tr_date:TrnObj.TrainDate to_code:TrnObj.TrainDestinationCode to_name:TrnObj.TrainDestination BordTime:TrnObj.TrainDepTime FromTime:TrnObj.TrainDepTime ToTime:TrnObj.TrainArrivalTime PNR_number:pnr_no];
}
[activityIndicator stopAnimating];
NSArray *seatdetails=[TrnObj.trainTicDictionary objectForKey:@"passengers"];
NSLog(@"SCRAPING self.seat_details %@",self.seat_details);
for(int i=0;i