NSURL of Temp Dir

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

  1. Zelda macrumors member

    Joined:
    Aug 10, 2014
    #1
    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.
    Thanks
    Z
     
  2. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    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

    Joined:
    Aug 10, 2014
    #3
    The Url has a value when i print it out, to create it, I am using
    Code:
    _audiofileURL = NSURL(string: NSTemporaryDirectory() + "filename")!.URLByAppendingPathExtension("caf")
    When I use the following..
    Code:
     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

    Joined:
    Aug 10, 2014
    #4
    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.
    Thanks
     

Share This Page