Reputation: 35
I have been given a task to replace all uint_8 * to NSMutableData. In the existing code, a lot of pointer arithmetic is done on uint8_t and then passed onto other APIs which also accept uint8_t *.
However, when replacing uint_8 * with NSMutableData, how do I pointer arithmetic on NSMutableData?
One approach is
however, when converting uint8_t * to NSMutableData, I do not have length.
How to solve this?
Old code
func(uint8_t *p);
func2() {
uint8_t *p; //points to some piece of memory
func(p+10); //pass base address+ 10 bytes
}
New Code
func(NSMutableData *p);
func2() {
NSMutableData *data = [[NSMutableData alloc]
initWithLength:size];
// now, how to pass data + 10 bytes to func
func(???)
}
Upvotes: 0
Views: 54