Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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???

like image 418
012346 Avatar asked Jan 21 '26 07:01

012346


2 Answers

try this

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

also see this answer..

how to convert NSData to char array containing hexa values

like image 84
Paras Joshi Avatar answered Jan 23 '26 08:01

Paras Joshi


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;
}
like image 33
nuynait Avatar answered Jan 23 '26 08:01

nuynait



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!