NSURL xcode 6.4

I was able to utilize the following code and the NSXMLParserDelegate methods to parse the contents of the https response. With migration to 6.4 from 6.2 the code no longer process the response properly. I am able to cut and paste the url and in the browser like chrome it returns a proper xml return. On safari it just returns line of string which does not make any sense to me. On Xcode 6.2 it used to work. I had to modify the func paser method due compile erors. The dictionary was changed to NSObject. What I don't understand is why foundCharters is never called. I have tested the structure with couple other different URL that return xml. Some of them seem to work.


Create the request:

let url: NSURL = NSURL(string: "https://test url")

parser = NSXMLParser(contentsOfURL: url)

parser.delegate = self

parser.parse()




Other methods for parser delegates:

func parser(parser: NSXMLParser, didStartElement elementName: String, namespaceURI: String?, qualifiedName qName: String?, attributes attributeDict: [NSObject : AnyObject]){

println("didStartElement Parser called")

element = elementName

attribues = attributeDict

println(element)

println(attribues)

}

func parser(parser: NSXMLParser??!, didEndElement elementName: String!, namespaceURI: String!, qualifiedName qName: String!){

println("didend element called")

}

func parser(parser: NSXMLParser?! ,foundCharacters string: String!){

println("found characters called")

if element == ("ticket"){

restckt = string

if restckt.isEmpty

{

/

}

else{

println("result ticket:\(restckt)")

insertfeedback(restckt)

}

}

}

Internally,

-initWithContentsOfURL:
calls
+[NSData dataWithContentsOfURL]
to fetch the data to parse. Try calling that yourself to see if you get back the XML data you’re expecting to get back.

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

I have the same problem with -[NSXMLParser initWithContentsOfURL] after updating to Xcode 7.0b5 and iOS 9. The parse method always returns false.

Following eskimo's advice (well, almost) I tried -[NSData initWithContentsOfURL] and that doesn't work either; returns nil.


After a bit of fiddling I've managed to get it to spurt out the following error:

App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.

See the App Transport Security Technote for an explanation of this.

Share and Enjoy

Quinn "The Eskimo!"
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
NSURL xcode 6.4
 
 
Q