objc警告:“从指针目标类型中丢弃限定符”

时间:2008-11-30 22:58:52

标签: iphone objective-c cocoa

编译时:

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

我收到了这个警告:

initialization discards qualifiers from pointer target type

如何摆脱它?

1 个答案:

答案 0 :(得分:27)

您缺少的限定符为const-UTF8String会返回const char *,因此str也应该声明为const char *