iOS 基础类解析 - NSData、NSMutableData
iOS 基础类解析 - NSData、NSMutableData
太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es)
本文遵循“署名-非商业用途-保持一致”创作公用协议
NSData Class Reference
Inherits from | |
Conforms to | |
Framework |
/System/Library/Frameworks/Foundation.framework
|
Availability |
Available in iOS 2.0 and later.
|
Declared in |
NSData.h
|
Companion guides | |
Related sample code |
Overview
NSData
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.
Tasks
Creating Data Objects
+ data
+ dataWithBytes:length:
+ dataWithBytesNoCopy:length:
+ dataWithBytesNoCopy:length:freeWhenDone:
+ dataWithContentsOfFile:
+ dataWithContentsOfFile:options:error:
+ dataWithContentsOfURL:
+ dataWithContentsOfURL:options:error:
+ dataWithData:
– initWithBase64EncodedData:options:
– initWithBase64EncodedString:options:
– initWithBytes:length:
– initWithBytesNoCopy:length:
– initWithBytesNoCopy:length:deallocator:
– initWithBytesNoCopy:length:freeWhenDone:
– initWithContentsOfFile:
– initWithContentsOfFile:options:error:
– initWithContentsOfURL:
– initWithContentsOfURL:options:error:
– initWithData:
– initWithBase64Encoding:
Deprecated
in iOS 7.0+ dataWithContentsOfMappedFile:
Deprecated
in iOS 5.0– initWithContentsOfMappedFile:
Deprecated
in iOS 5.0
Accessing Data
– bytes
– description
– enumerateByteRangesUsingBlock:
– getBytes:length:
– getBytes:range:
– subdataWithRange:
– rangeOfData:options:range:
– getBytes:
Deprecated
in iOS 4.0
Base-64 Encoding
– base64EncodedDataWithOptions:
– base64EncodedStringWithOptions:
– base64Encoding
Deprecated
in iOS 7.0
Testing Data
Storing Data
Copyright © 2014 Apple Inc. All Rights Reserved. Terms of Use | Privacy
Policy | Updated: 2014-02-11
最新文章
- BZOJ3160万径人踪灭
- Oracle 编程
- 这些年正Android - 身在他乡
- 数学对象-Math
- Entity Framework 的简单介绍与实例
- 静态类和静态类成员(C# 编程指南)
- 【转】利用 Bootstrap 进行快速 Web 开发
- final specifier (since C++11)
- C# 越来越复杂了
- C#快速学习笔记(译)
- throw 与 throws的应用
- 关于 gravity与layout_gravity
- 各浏览器对 window.open() 的窗口特征 sFeatures 参数支持程度存在差异
- java实现简单web服务器(分析+源代码)
- @Transactional注解详解
- vDSP加速的应用
- Linux 实例常用内核网络参数介绍与常见问题处理
- SqlServer 查看最近执行过的语句
- 关于浏览器对html, js,css的解析先后顺序的理解
- 【翻译】go memory model