Ric
Ric

Reputation: 796

how do you encode a NULL char (\000) into NSData?

how do you encode a NULL char (\000) into NSData ? I cannot fathom how to do this. I ultimately want this to be part of a larger data string that I construct, but I can't figure out how to bring it in.

Upvotes: 1

Views: 1430

Answers (1)

Ole Begemann
Ole Begemann

Reputation: 135550

NSMutableData *data = [NSMutableData data];
unsigned char zeroByte = 0;
[data appendBytes:&zeroByte length:1];

Upvotes: 6

Related Questions