The docs for NSURL
state that:
An NSURL object represents a URL that can potentially contain the location of a resource on a remote server, the path of a local file on disk, or even an arbitrary piece of encoded data.
I have a blob of in-memory data that I'd like to hand to a library that wants to load a resource via an NSURL
. Sure, I can first write this NSData
to a temp file and then create a file://
NSURL
from that, but I'd prefer to have the URL point directly to the buffer that I already have present in memory.
The docs quoted above seem to suggest this is possible, but I can't find any hint of how to accomplish it. Am I missing something?
[NSData dataWithContentsOfURL:myURLHere]
to give the data that you already have in RAM instead of reading it from a file? – AlricNSData
makes a few references todata://
as a supported URL protocol, but I can't find any documentation for exactly how it works. Most likely it's just the data as a hex string? – Alric