我们如何清除NSMutableData中的内容 [英] How do we clear out contents in NSMutableData

查看:107
本文介绍了我们如何清除NSMutableData中的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在不使用release的情况下清除NSMutableData,然后再次重新分配/ init再次使用?
我看着resetBytesInRange设置为零,但我不确定这一点。有人可以提供帮助吗?

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?

推荐答案

如果你想要一个空的缓冲区:

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])];

这篇关于我们如何清除NSMutableData中的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆