NSData *data; data = [self fillInSomeStrangeBytes];
My question is now how I can write this data
on the easiest way to an file.
(I've already an NSURL file://localhost/Users/Coding/Library/Application%20Support/App/file.strangebytes
)
A static byte buffer that bridges to Data ; use NSData when you need reference semantics or other Foundation-specific behavior.
Data and NSData are types used to interact with raw binary data. They're commonly used to hold raw data more complex than single strings, integers, bools, and so on.
NSMutableData is “toll-free bridged” with its Core Foundation counterpart, CFData . See Toll-Free Bridging for more information on toll-free bridging. Important. The Swift overlay to the Foundation framework provides the Data structure, which bridges to the NSMutableData class and its immutable superclass NSData .
NSData
has a method called writeToURL:atomically:
that does exactly what you want to do. Look in the documentation for NSData
to see how to use it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With