title: Xml Parser delegate not call in Swift
body: <p>I have a web service which give <code>xml</code> response. I want to parse and show in table. But my <code>XMLParser</code> delegate not called. I am newer in swift. Please help any help would be apperciated,</p>
  
  <pre><code>class ViewController: UIViewController,NSXMLParserDelegate,UITableViewDelegate {
          var element:String?
          var titles:NSMutableString?
          var link:NSMutableString?
          var tableData:NSMutableArray?
          var dict:NSMutableDictionary?
       @IBOutlet weak var table: UITableView?
          override func viewDidLoad() {
              super.viewDidLoad()
              dict = NSMutableDictionary()
              tableData = NSMutableArray()
              let url = NSURL(string: "hp?keytext=s")
              let theRequest = NSURLRequest(URL: url)
  
              NSURLConnection.sendAsynchronousRequest(theRequest, queue: nil, completionHandler: {(response: NSURLResponse!, data: NSData!, error: NSError!) -&gt; Void in
                  if data.length &gt; 0 &amp;&amp; error == nil {
  
                   //var   parser=NSXMLParser(data: data)
                 var parser = NSXMLParser(contentsOfURL: url)
                      parser.delegate=self
                      parser.shouldResolveExternalEntities=false
                   parser.parse()
                  }
              })
              // Do any additional setup after loading the view.
  
  
  
  
          }
  
          override func didReceiveMemoryWarning() {
              super.didReceiveMemoryWarning()
              // Dispose of any resources that can be recreated.
          }
  
          func tableView(tableView: UITableView?, numberOfRowsInSection section: Int) -&gt; Int {
  
              // Return the number of rows in the section.
              return tableData!.count
          }
  
          func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -&gt; UITableViewCell! {
  
                    var cell = tableView.dequeueReusableCellWithIdentifier("CELL") as? UITableViewCell
  
  
              if !(cell != nil) {
                         cell = UITableViewCell(style: UITableViewCellStyle.Value1, reuseIdentifier: "CELL")}
  
  
  
              var a:NSString
              var b:String
  
              a = tableData?.objectAtIndex(indexPath.row).objectForKey("title") as NSString
              b = tableData?.objectAtIndex(indexPath.row).objectForKey("city") as NSString
  
              cell?.textLabel?.text=a;
               cell?.detailTextLabel?.text=b
  
  
  
  
              return cell
  
  
  
  
          }
  
          func tableView(tableView:UITableView, heightForRowAtIndexPath indexPath:NSIndexPath)-&gt;CGFloat
  
          {
  
              return 78;
  
          }
  
  
          func parser(parser: NSXMLParser, didStartElement elementName: String, namespaceURI: String, qualifiedName qName: String, attributes attributeDict: [NSObject : AnyObject]) {
              element=elementName
              if element=="restaurant"
              {
                  titles=NSMutableString()
                  link=NSMutableString()
              }
  
          }
  
          func parser(parser: NSXMLParser, foundCharacters string: String) {
              if element=="title"
              {
                  titles?.appendString(string)
              }
              else if element=="city"
              {
                  link!.appendString(string)
              }
          }
  
  
          func parser(parser: NSXMLParser, didEndElement elementName: String, namespaceURI: String, qualifiedName qName: String) {
              if elementName == "restaurant"
              {
                  dict?.setValue(titles, forKeyPath: "title")
                  dict?.setValue(link, forKeyPath: "city")
                  tableData?.addObject(dict!)
  
              }
          }
  
          func parserDidEndDocument(parser: NSXMLParser!){
  
              table?.reloadData()
  
          }
  
      }
  </code></pre>