Sample code for 30+ languages & platforms
Objective-C

Appending Strings to BinData

Demonstrates appending strings to a BinData..

Chilkat Objective-C Downloads

Objective-C
#import <CkoBinData.h>

CkoBinData *binData1 = [[CkoBinData alloc] init];

//  Append a string using a 1-byte per char encoding
[binData1 AppendString: @"This is a test" charset: @"windows-1252"];
NSLog(@"%@",[binData1 GetEncoded: @"hex"]);
//  The bytes contained within the binData1 (in hex) are: 54,68,69,73,20,69, ...

CkoBinData *binData2 = [[CkoBinData alloc] init];

//  Append a string using a 2-byte per char encoding
[binData2 AppendString: @"This is a test" charset: @"utf-16"];
NSLog(@"%@",[binData2 GetEncoded: @"hex"]);
//  The bytes contained within the binData2 (in hex) are: 54,00,68,00,69,00,73,00,20,00,69,00, ...