user1849064
user1849064

Reputation: 31

cocos2d-x Convert nsstring to char*

NSString *_str=@"rank";
const char *color_char1 = [_str cStringUsingEncoding:NSASCIIStringEncoding];

I run it in iphone 6.0 Simulator, it works fine; but when I run it on new iPad it crashes.

I can't get color_char1 ,why?

Upvotes: 3

Views: 825

Answers (2)

KARTHIK  RA
KARTHIK RA

Reputation: 469

try this code.

NSString *_str=@"rank";

const char *color_char1 = (char *)_str;

Upvotes: 0

JohannesRu
JohannesRu

Reputation: 160

const char * myChar = [@"hey I am an NSString" UTF8String];

That should work :D

Upvotes: 2

Related Questions