Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我们如何在不使用释放的情况下清除 NSMutableData,然后再次重新分配/初始化以再次使用?我正在查看将 resetBytesInRange 设置为零,但我不确定这一点。任何人都可以帮忙吗?
如果你想要一个空缓冲区:
[data setLength:0];
如果要保持其大小但将所有字节设置为零:
[data resetBytesInRange:NSMakeRange(0, [data length])];
将所有字节设置为零的 Swift 版本:
data.resetBytes(in: NSRange(location:0, length:data.length))