last day (14 days later) » 

2:04 PM
0
A: Parsing data in Swift - issue

tom.alexanderYou are trying to parse XML. Here's how you might do it: let urlPath:NSURL = NSURL(scheme:"http", host:"example.net", path:"example/example.php") var error: NSErrorPointer? = nil var xml:NSXMLDocument = NSXMLDocument(contentsOfUrl: urlPath, error: error!) At that point, xml will represent an N...

 
CAN
I have tried that but it is not working again crashing the same place.
 
Wait, sorry, i just noticed your update. You're trying to parse XML?
 
CAN
Sorry yes, I am trying to parse xml.
 
Updated my answer
 
CAN
NSXMLDocument is undeclared type? I have wrote delegate NSXMLParserDelegate
 
2:04 PM
Have you done an import Foundation?
 
CAN
Yes I did.
 
Hey there
It actually looks like Apple has not implemented NSXMLDocument in Swift yet :(
A guy wrote an XML parsing lib for Swift that gets around this. Check it out: github.com/ndavidsson/NDHpple
Here is an example on how to use it with a URL Schema: github.com/ndavidsson/NDHpple/blob/master/NDHpple/…
 
CAN
Oh I see that... I should change the XML to JSON to make it easier.
 
yeah then it would be much easier
and JSON is more of the "winning" standard in tech
 
CAN
Ok Thank you very much. Should I keep the question open like that?
 
2:14 PM
It's a bit confusing now to people because you switched from JSON -> XML. I think the answer provided will show people how to do it in Swift. I'd choose the best answer and then open up a different question around JSON parsing in Swift
but this question should help you parse JSON data in Swift. It's a pretty good example and is exactly what you're trying to do: stackoverflow.com/questions/24026305/…
 
CAN
Thank you for your help I appreciate. That link will help me a lot once I convert my XML to JSON.
 
:) absolutely
best of luck
I'm building my 4th app in Swift and it can be confusing, especially since there isn't a strong community for it yet
eventually, this stuff will be trivial, but for now we have to run through the mud
 

last day (14 days later) »