NSData bytes readonly?

72 views Asked by At

According to the GNUstep documentation, [NSData bytes] returns const void*.

Does that mean that I'm not supposed to modify the data referenced by that pointer?

Currently I'm modifying the data, and it works for me. I can write to a file and the modified data go there.

1

There are 1 answers

1
Gershon Hochman On BEST ANSWER

NSData is unmutable by definition. Use NSMutableData instead.`

NSMutableData *mutableData = [[NSMutableData alloc] initWithData:data];
void *pointerToMutableBytes = [mutableData mutableBytes];