I'd like to get a pointer to the object stored in an NSValue
so that I can modify it. The gist being like this:
// Get a pointer to the value's buffer (it'd be void*, I guess).
CGRect *myRect = [rectValue getPointer];
// Modify the rectangle.
myRect->origin = CGPointMake(10, 10);
I notice NSValue
has the method pointerValue
, but the documentation says:
The value as a pointer to void. If the value object was not created to hold a pointer-sized data item, the result is undefined.
… so this only seems to be suitable for values that are pointers, which this isn't, it's a CGRect
.
Incidentally, if the answer is "you can't do this", that still a good answer as far as I'm concerned :-) An explanation of why not would be interesting, as it seems like an amazingly obvious absence in the API.