Cannot Find Pdf File being created in Swift XCode

Iv used the following Code from Tom to create a Pdf File and

PDF Generation Swift

im having the same problem finding the document I created using Tom's code. Iv search my Mac HD and still no document and the programme does not crash. And when i look at the log it shows it has been stored at the following path

pdfPathWithFileName String "/Users/cleota/Library/Developer/CoreSimulator/Devices/B72A97D0-339E-4E79-AED6-4991D3B7C4B7/data/Containers/Data/Application/7A7789C4-27C5-45FB-8604-E36865609764/Documents/Ezy Essay Test.pdf"

but when I go there these folders(Library/Developer/CoreSimulator/Devices)are not there where it says it has been stored. Thoughts please?

    @IBAction func createPdfDocument(sender: AnyObject) {

    let fileName: String = "Taumaoe.pdf"
    let path:NSArray = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
    let documentDirectory: AnyObject = path.objectAtIndex(0)
    let pdfPathWithFileName = documentDirectory.stringByAppendingPathComponent(fileName as String)




func generatePdf(filepath: String){

    UIGraphicsBeginPDFContextToFile(filepath, CGRectZero, nil)
    UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, 850, 1100), nil)


func drawBackground(){

    var context:CGContextRef = UIGraphicsGetCurrentContext()!

   // var rect:CGRect = CGRectMake(0, 0, CGSize.height, CGSize.width)
    //CGContextSetFillColorWithColor(context, UIColor.greenColor().CGColor)
    //CGContextFillRect(context, rect)

    var testView = UIView (frame: CGRectMake(0,0,850,1100))
    testView.backgroundColor = UIColor.yellowColor()

    var label = UILabel (frame: CGRectMake(10,10,100,20))
    label.textColor = UIColor.redColor()
    label.backgroundColor = UIColor.lightGrayColor()
    label.text = "I'am a test label"



    //Title of 1st option of MainController

            let sexyKeyWordscontroller = UIAlertController(title: "Ezy Essay Saved!", message: "Well done! Your Ezy Essay Pdf document has been saved at the following path: ", preferredStyle: UIAlertControllerStyle.Alert)

            let closeButton : UIAlertAction = UIAlertAction(title: "Close",
                style: UIAlertActionStyle.Cancel,
                handler: {
                    (alert: UIAlertAction!) in sexyKeyWordscontroller.dismissViewControllerAnimated(true,
                        completion: nil)


            self.presentViewController(sexyKeyWordscontroller, animated: true, completion: nil)




If you print out pdfPathWithFileName in the button event you will get the file path. When you have the file path open a finder window and in the file menu click: Go > Go to folder

The path that you have printed out will look something like this:


Copy this into the Go to folder from the path


And of course skip the last "/xp.pdf" in the path if you only want to open the location of the folder and not the file itself.

Need Your Help

PHP Curl can't fetch data from any url

php linux curl

I am trying to fetch some data with this code

What's the best way to allow queries/views to see how tables looked in the past based on a datetime stamp in SQL Server 2008?

sql-server database-design sql-server-2008

Scenario: We have a great deal of server environmental information (names, IPs, roles, firewall ports, etc.). Currently it's stored in a big Excel workbook on a SharePoint, which trivially allows...