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?

Answers


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


Need Your Help

Saving images in sql with php collation

php sql image

I am trying to save some png images in my database, but from the error i get

Store some records in the application and some in the database?

php mysql web-applications

I have an application where it seems as if it would make sense to store some records hard-coded in the application code rather than an entry in the database, and be able to merge the two for a common

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.