---
title: "OBEXHeadersToBytes(_:)"
framework: IOBluetooth
role: symbol
role_heading: Function
path: "iobluetooth/obexheaderstobytes(_:)"
---

# OBEXHeadersToBytes(_:)

Converts a dictionary of headers to a data pointer, from which you can extract as bytes and pass to the OBEX command/response functions.

## Declaration

```swift
func OBEXHeadersToBytes(_ dictionaryOfHeaders: CFDictionary!) -> Unmanaged<CFMutableData>!
```

## Parameters

- `dictionaryOfHeaders`: Dictionary that you have added headers to with the above OBEXAddXXXHeader functions.

## Return Value

Return Value Mutable data ref containing the bytes of all headers.

## Discussion

Discussion Returns a CFMutableDataRef containing all the header data found in the dictionary, formatted according to the OBEX/IrMC spec. YOU MUST RELEASE IT when you are finished with it (ie. when the OBEX request is complete). All OBEX-specification defined headers are supported and should be returned to the dictionary. Use the keys defined above to get headers from dictionary. Example usage:      Example usage:      CFMutableDictionaryRef	dictionary;    CFMutableDataRef		mGetHeadersDataRef;    uint8_t* 				headerDataPtr;    uint32_t 				headerDataLength;      dictionary = CFDictionaryCreateMutable( kCFAllocatorDefault, 0, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks );      // Package up desired headers.      OBEXAddTypeHeader( CFSTR( "text/x-vCard" ), dictionary );      mGetHeadersDataRef = OBEXHeadersToBytes( dictionary );      headerDataPtr = CFDataGetBytePtr( mGetHeadersDataRef );    headerDataLength = CFDataGetLength( mGetHeadersDataRef );      // From here I can pass it to any OBEX command, such as OBEXPut...

## See Also

### Miscellaneous

- [OBEXAddApplicationParameterHeader(_:_:_:)](iobluetooth/obexaddapplicationparameterheader(_:_:_:).md)
- [OBEXAddAuthorizationChallengeHeader(_:_:_:)](iobluetooth/obexaddauthorizationchallengeheader(_:_:_:).md)
- [OBEXAddAuthorizationResponseHeader(_:_:_:)](iobluetooth/obexaddauthorizationresponseheader(_:_:_:).md)
- [OBEXAddBodyHeader(_:_:_:_:)](iobluetooth/obexaddbodyheader(_:_:_:_:).md)
- [OBEXAddByteSequenceHeader(_:_:_:)](iobluetooth/obexaddbytesequenceheader(_:_:_:).md)
- [OBEXAddConnectionIDHeader(_:_:_:)](iobluetooth/obexaddconnectionidheader(_:_:_:).md)
- [OBEXAddCountHeader(_:_:)](iobluetooth/obexaddcountheader(_:_:).md)
- [OBEXAddDescriptionHeader(_:_:)](iobluetooth/obexadddescriptionheader(_:_:).md)
- [OBEXAddHTTPHeader(_:_:_:)](iobluetooth/obexaddhttpheader(_:_:_:).md)
- [OBEXAddLengthHeader(_:_:)](iobluetooth/obexaddlengthheader(_:_:).md)
- [OBEXAddNameHeader(_:_:)](iobluetooth/obexaddnameheader(_:_:).md)
- [OBEXAddObjectClassHeader(_:_:_:)](iobluetooth/obexaddobjectclassheader(_:_:_:).md)
- [OBEXAddTargetHeader(_:_:_:)](iobluetooth/obexaddtargetheader(_:_:_:).md)
- [OBEXAddTime4ByteHeader(_:_:)](iobluetooth/obexaddtime4byteheader(_:_:).md)
- [OBEXAddTimeISOHeader(_:_:_:)](iobluetooth/obexaddtimeisoheader(_:_:_:).md)
