Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

objc warning: "discard qualifiers from pointer target type"

When compiling this:

char *str = [[NSString stringWithFormat:@"%i days and %i hours", days, hours] UTF8String];

I get this warning:

initialization discards qualifiers from pointer target type

How do I get rid of it?

like image 814
Steph Thirion Avatar asked Nov 30 '08 22:11

Steph Thirion


1 Answers

The qualifier you’re missing is const. -UTF8String returns a const char *, so str should also be declared const char *.

like image 56
Jens Ayton Avatar answered Nov 02 '22 14:11

Jens Ayton