NSData Class Reference
| Inherits from |
NSObject |
| Conforms to |
nscopying nsmutablecopying nssecurecoding NSObject (nsobject)
|
| framework |
/system/library/frameworks/foundation.framework |
| availability |
available in IOS 2.0 and later. |
| declared in |
nsdata.h |
| companion guides |
binary Data Programming Guide property List Programming Guide |
| Related Sample Code |
advancedurlconnectionscryptoexerciseEademomvcnetworkingsimpleurlconnections |
Overview
nsdata and its mutable subclass nsmutabledata provide Data Objects, object-oriented wrappers for byte buffers. Data Objects-let-allocated buffers (that's, data with no embedded pointers) take on the behavior of Foundation obj ECTs.
NSDataCreates static data objects, and NSMutableData creates dynamic Data objects. And is NSData NSMutableData typically used for data storage a ND is also useful in distributed Objects applications, where data contained on data Objects can be copied or moved Betwee n Applications.
The size of the data is subject to a theoretical limit of about 8 exabytes (in practice, the limit should isn't be a factor) .
NSDataIs ' toll-free bridged ' with its Core Foundation counterpart, CFDataRef . See "Toll-Free bridging" for more information on toll-free bridging.
Taskscreating 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:
– base64EncodingDeprecated in IOS 7.0
Testing Data
– isEqualToData:
– length
Storing Data
– writeToFile:atomically:
– writeToFile:options:error:
– writeToURL:atomically:
– writeToURL:options:error:
Copyright? Apple INC. All rights Reserved. Terms of Use | Privacy Policy | Updated:2014-02-11