I have two questions.
-
How to create a NSFileHandle object with the FILE* instance?
-
How to create a NSData object with the void* instance?
I am sorry there’s little information without context.
Just refer to my recent question. Weird behavior of fopen on ios I cannot use the native fopen function to create or to write the content into a file.
As a result, I just want to use the api in the ios framework and wrap the code of fopen and fwrite and such staff. So I should convert the FILE* object into NSFileHandle or something that can manipulate the file. Also the content which is handled with void* should be converted to the data format that can be accepted in the ios framework. And I think NSData should be the choice.
As for FILE* to NSFileHandle, I found this mailing list question that perfectly matches what you need. Relevant code:
And it comes with a lovely warning from the answerer:
EDIT: As for void* to NSData, I think you want
NSData's -initWithBytesNoCopy:Length:freeWhenDone:. See this related question on how to use it.