views:

2758

answers:

2
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)

+6  A: 

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.

Alex
Watch out for endian issues.
Georg
+4  A: 

writeToURL:atomically: or writeToFile:atomically: if you have a filename instead of a URL.

Brian Campbell