2014-10-28 127 views
0

我正在使用XML解析器,同時我從服務器獲取多個url數據。 因此,在iOS 6和iOS 7中它的工作正常,但在iOS 8中解析器被阻止。 請查看屏幕截圖。iOS 8中的XML解析器問題

我正在使用dispatch_queue_t(app.forgroundQueue)。

enter image description here

檢查這裏的代碼

AppDelegate *app = (AppDelegate *) [[UIApplication sharedApplication]delegate]; 
      app.isSerialQueueRunning =YES; 
      dispatch_async(app.forgroundQueue, ^{ 
      [self setDelegate:aDelegate]; 
      self.responseArray =[[NSMutableArray alloc] init]; 
      NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[url stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]]]; 
      NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration] delegate:self delegateQueue:nil]; 
      NSURLSessionDataTask *task = [session dataTaskWithRequest:request 
                completionHandler: 
              ^(NSData *data, NSURLResponse *response, NSError *error) { 
                if (!error) 
                { 
                } 
                else 
                { 
                  if ([_delegate respondsToSelector:@selector(ConnectionMessage:)]) 
                  { 
                    [_delegate ConnectionMessage:@"Parsing Fail Please Check internet Connection or Refresh Again"]; 
                  } 
                } 

                NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data]; 
                [parser setDelegate:self]; 
                [parser setShouldResolveExternalEntities:NO]; 
                [parser parse]; 
                [email protected]"NO"; 

              }]; 
      [task resume]; 

        }); 
+0

粘貼代碼在這裏,它會幫助其他人測試你的代碼? – 2014-10-28 11:28:06

+0

是的,用代碼 – Piyush 2014-10-28 11:35:59

回答

0

我也有類似的問題,儘量確保在主隊列發送parse消息:

// Start on main thread 
dispatch_async(dispatch_get_main_queue(), ^{ 
    [parser parse]; 
}); 
+0

更新問題,但已經創建了一個新的dispatch_queue_t並在其中添加代碼。 dispatch_async(app.forgroundQueue,^ {//解析器代碼 }); – Piyush 2014-10-28 11:49:59

+0

再次出現同樣的問題EXE_BAD_ACCESS。 – Piyush 2014-10-28 11:52:19

+0

您是否檢查過「數據」實際包含的內容? – jjv360 2014-10-28 11:59:39