012346
012346

Reputation: 199

How To convert NSData to Char?

I have a NSdata (License_Data <0d2b3931 39323433 37363637 36360c79 70617963 6173682d 50445301 0010322d 22772a17 24599e96 88be9991 b2410106>) like this

When i Convert this to char after this 00 ,It is not taking any value

0010322d
Char*c=[Lincense_Data bytes];

Is thr any method other than this which take even Zero also ,Anyone Please Help???

Upvotes: 3

Views: 17704

Answers (2)

nuynait
nuynait

Reputation: 1962

For Objective-C++, This is how I convert the NSData to char *

NSData *data = [...]; // This is your data
if (data) {
    const void *_Nullable rawData = [data bytes];
    char *src = (char *)rawData;
}

Upvotes: 3

Paras Joshi
Paras Joshi

Reputation: 20541

try this

unsigned char *bytePtr = (unsigned char *)[data bytes];

also see this answer..

how to convert NSData to char array containing hexa values

Upvotes: 11

Related Questions