Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do we clear out contents in NSMutableData

How do we clear an NSMutableData without using release and then re-alloc/init again to be used again? I was looking at resetBytesInRange to be set at zero but I am unsure of this. Anyone can help?

like image 946
Frank Avatar asked Dec 11 '09 20:12

Frank


1 Answers

If you want an empty buffer:

[data setLength:0]; 

If you want to keep its size but set all the bytes to zero:

[data resetBytesInRange:NSMakeRange(0, [data length])]; 
like image 77
benzado Avatar answered Sep 21 '22 14:09

benzado