NSURL of Temp Dir

Discussion in 'iOS Programming' started by Zelda, May 30, 2016.

  1. Zelda macrumors member

    Aug 10, 2014
    I have an AudioFile in the temp dir and trying to share via UIActivityViewController, however
    the NSURL is not recognised..
    Any ideas or suggestions would be appreciated.
  2. PhoneyDeveloper macrumors 68040


    Sep 2, 2008
    What is the value of the NSURL if you print it out? How do you create it? How do you know it isn't recognized?
  3. Zelda, May 31, 2016
    Last edited: May 31, 2016

    Zelda thread starter macrumors member

    Aug 10, 2014
    The Url has a value when i print it out, to create it, I am using
    _audiofileURL = NSURL(string: NSTemporaryDirectory() + "filename")!.URLByAppendingPathExtension("caf")
    When I use the following..
     var  shareView = UIActivityViewController!(nil)
            shareView = UIActivityViewController(activityItems: [_audiofileURL!], applicationActivities:nil )
                    self.presentViewController(shareView,animated:true,completion: nil )
    nothing appears in the modal view.
    The funny thing is, if I skip using the temp dir and just save the file in the Documents dir, it works, however it only works once, that is, I share the file or cancel from the UIActivityViewController and second go at sharing the file, it is not recognised, nothing in the modal view.

    After the second attempt at sharing, I get this in the console.
    Error: NSCocoaErrorDomain
  4. Zelda thread starter macrumors member

    Aug 10, 2014
    OK, I sorted this particular problem, I was deleting the file in the viewWillDisappear function.
    Now it's time to see if I am creating a URL for the Temp dir correctly.

Share This Page