iOS 基础类解析 - NSData

来源:互联网 发布:淘宝买家也可以开店吗 编辑:程序博客网 时间:2024/06/05 15:51

OverviewNSData  and its mutable subclass  NSMutableData  provide data objects, object-oriented wrappers for byte buffers. Data objects let simple allocated buffers (that is, data with no embedded pointers) take on the behavior of Foundation objects.NSData  creates static data objects, and  NSMutableData  creates dynamic data objects.  NSData  and  NSMutableData  are typically used for data storage and are also useful in Distributed Objects applications, where data contained in data objects can be copied or moved between applications.The size of the data is subject to a theoretical limit of about 8 ExaBytes (in practice, the limit should not be a factor).NSData  is “toll-free bridged” with its Core Foundation counterpart,  CFDataRef . See  “Toll-Free Bridging”  for more information on toll-free bridging.


NSData相当于Java的字节缓冲区。

NSData和NSMutableData存储的是二进制数据,在文件操作,网络,以及核心图形图像中使用较广泛。NSData创建后不可以再修改,NSMutableData可以再次修改。

ByteBuffer其实就是一个字节缓冲区, 在这里你可以对缓冲区的数据进行字节级的操作. 这样的好处在于你可以比较方便的获取到底层的字节操作和字节数据
0 0