Cocoa & Cocoa Touch. How do I create an NSData object from a plain ole pointer?

Posted by dugla on Stack Overflow See other posts from Stack Overflow or by dugla
Published on 2010-06-11T20:07:33Z Indexed on 2010/06/12 15:23 UTC
Read the original article Hit count: 315

Filed under:
|
|
|

I have malloc'd a whole mess of data in an NSOperation instance. I have a pointer:

data = malloc(humungous_amounts_of_god_knows_what);
uint8_t* data;

How do I package this up as an NSData instance and return it to the main thread? I am assuming that after conversion to an NSData instance I can simply call:

free(data);

Yes?

Also, back on the main thread how do I retrieve the pointer?

Thanks,
Doug

© Stack Overflow or respective owner

Related posts about cocoa-touch

Related posts about malloc