Playgrounds are sandboxed, so you won't be able to just grab files from anywhere in your user folder. Here's how to add that file to your playground to make it accessible:
- Find your ".playground" file in the Finder
- Right click and choose "Show Package Contents"
- You should see "timeline.xctimeline", "contents.xcplayground", and "section-1.swift"
- Make a new folder called "Resources"
- Copy "app.xml" into that new folder
Now your file will be available inside the sandbox. You can retrieve it from the bundle and load it into the NSXMLParser
like this:
let url: NSURL! = NSBundle.mainBundle().URLForResource("app", withExtension: "xml")
var xml = NSXMLParser(contentsOfURL: url)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…