The signature of -[NSData bytes]
is - (const void *)bytes
. You can't assign a pointer to an array on the stack. If you want to copy the buffer managed by the NSData
object into the array, use -[NSData getBytes:]
. If you want to do it without copying, then don't allocate an array; just declare a pointer variable and let NSData
manage the memory for you.