Search code examples
swift2nsdatansurl

SWIFT: NSData contentsOfUrl returns nil from valid URL


I have an URL (NOT A path or a string): file:///private/var/mobile/Containers/Data/Application/50558DAA-7082-4BB0-AB0C-F7BA0DC483E5/tmp/yFFaofWcIWln-SCVideo-Merged.mp4

When I use NSData(contentsOfUrl: url) i get nil.

I have tried same code with an asset from library URL without any problems.

Is there a difference in the two URLS? Anybody knows how to extract NSData from the above URL?

Thanks in advance

EDIT: Seems like there was a problem with the actual file, for some reason it contained only audio and no video. Needs further investigating. Thanks for your contributions.


Solution

  • In my specific case, it was the actual data in the URL that was missing... So that is why it returned nil.

    Thanks guys for trying to help :)