ios - NSXMLParser is not being called in Swift 2.0 (Could not open data stream) -


i trying nsxmlparser work in swift 2.0. had working parser in swift 1. migrated swift 2.0 , parser not kick off properly.

init(urltouse: string) {     self.eventfeedurl = urltouse     super.init() }  func beginparsing() {     // should kick off parsing functionality      // lastdate starts off current date/time , used later update available articles     var lastdate = nsdate()      let feedurl:nsurl = nsurl(string: self.eventfeedurl)!      let feedparser:nsxmlparser? = nsxmlparser(contentsofurl: feedurl)      if let actualfeedparser = feedparser {          // download feed , parse out         actualfeedparser.delegate = self          actualfeedparser.parse()      }  }  func getavailableevents() -> [event] {     return self.availableevents }  func updateavailableevents(newevents:[event]) {     // add new day's events avaiable events     self.availableevents += newevents      // notify new events available parser     notificationcenter.postnotificationname("cityofboston_eventsupdated", object: self)  }   // xml parsing functions specific feed func parser(parser: nsxmlparser, didstartelement elementname: string, namespaceuri: string?, qualifiedname qname: string?, attributes attributedict: [string : string]) {     // add other xml tags care if statement below (via || (or) logic)      if elementname == "item" || elementname == "title" ||  elementname == "link" || elementname == "description" || elementname == "category" {          self.currentelement = elementname         self.attributes = attributedict      }      if elementname == "item" {          // start new event         self.currentlyconstructingevent = event()      } }  func parser(parser: nsxmlparser, foundcharacters string: string) {     // add other xml tags care if statement below (via || (or) logic)     if self.currentelement == "item" ||         self.currentelement == "title" ||         self.currentelement == "description" ||         self.currentelement == "link" ||         self.currentelement == "category"{              self.foundcharacters += string      } }  func parserdidenddocument(parser: nsxmlparser) {     notificationcenter.postnotificationname("cityofboston_parserfinished", object: self) }  func parser(parser: nsxmlparser, didendelement elementname: string, namespaceuri: string?, qualifiedname qname: string?) {      if elementname == "title" {         // parsing of title element complete, save data          // update appropriate title formatting         foundcharacters = foundcharacters.stringbytrimmingcharactersinset(nscharacterset.whitespaceandnewlinecharacterset())         foundcharacters = foundcharacters.stringbyreplacingoccurrencesofstring("'", withstring: "'", options: [], range: nil)         let title:string = foundcharacters.stringbyreplacingoccurrencesofstring(""", withstring: "\"", options: [], range: nil)         self.currentlyconstructingevent.seteventtitle(title) 

problem issue transport security in latest version here.

so should nsapptransportsecurity dictionary info.plist. add nsallowsarbitraryloads key dictionary , set boolean value true.

<key>nsapptransportsecurity</key>        <dict>             <key>nsallowsarbitraryloads</key><true/>        </dict>   

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -