NSMutableData * data = [NSMutableData dataWithData:jsonData];
This should solve your problem.
Question
is there some way to convert an NSData
object, into an NSMutableData one? Basically I am using NSJSONSerialization
which basically takes some JSON data I receive and transforms it into an NSData
object instance. Is there anyway to then transform this into an NSMutableData
object instance? I need to do this because later on, I will be spawning some threads and within the code blocks I provide, I would like to change the value of the Data object. I can't do that if its NSData
but I can if its NSMutableData
.
No correct solution
OTHER TIPS
NSMutableData * data = [NSMutableData dataWithData:jsonData];
This should solve your problem.
You can use below code:
NSData *data = ...;
NSMutableData *mutableData = [[NSMutableData alloc] initWithData:data];