NSMutableData remove bytes?

后端 未结 4 508
半阙折子戏
半阙折子戏 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:41

    If the data you want to remove is at the end, you can use

    [NSMutableDataInstance setLength:[NSMutableDataInstance length] - n];

    or with the obj-c 2.0 syntax

    NSMutableDataInstance.length -= n;
    

    for anything more complicated than that I'd recommend manipulating the raw data.

提交回复
热议问题