objective-cpointersmemory-managementnsvalue

Does NSValue free its value when freed?


Have a look at this pseudocode:

void* magicpointer = malloc(OVER_NINE_THOUSAND);
NSValue* v = [NSValue valueWithPointer:magicpointer];
[v release];

When v is released, does magicpointer get freed as well, or do I have to do that manually? I am using manual reference counting.


Solution

  • It doesn't get freed - NSValue is just a wrapper so you can treat arbitrary values as objects. It doesn't do anything with the wrapped pointer.