NSMutableData remove bytes?

后端 未结 4 489
半阙折子戏
半阙折子戏 2021-02-02 09:25

I can add bytes to a NSMutableData instance easily by using the appendData method, however I do not see any similar method for removing data? Am I overlooking somet

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-02 09:48

    I see that this thread has the answer, but nevertheless this could be valuable add. To remove all bytes from NSMuttableData, you can create new Data and copy it to original:

    [myData setData:[NSData dataWithBytes:NULL length:0]];
    

    This works great.

提交回复
热议问题