iOS NSURL of Temp Dir

Zelda

macrumors member
Original poster
Aug 10, 2014
39
2
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
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
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?
 

Zelda

macrumors member
Original poster
Aug 10, 2014
39
2
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
 
Last edited:

Zelda

macrumors member
Original poster
Aug 10, 2014
39
2
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
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.