OGeek|极客世界-中国程序员成长平台

标题: iphone - 格式说明符 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 22:47
标题: iphone - 格式说明符

我正在使用 this code来自一个男人

在这段代码的中间,我们有

- (NSString *)hexStringFromColor {
        return [NSString stringWithFormat"%0.6X", self.rgbHex];
}

这在 Xcode 4.4 之前工作正常。现在,我看到了这个错误: format 指定类型 unsigned int 但参数的类型为 UInt32(又名 unsigned long)。

为什么 Xcode 在 4.4 中会出现问题,但之前没有?我应该使用什么说明符?

谢谢。



Best Answer-推荐答案


由于 rgbHex 似乎是一个无符号长整数,因此正确的格式说明符是 @"%0.6lX" 其中 l 代表 .

List of iOS String Format Specifiers .

关于iphone - 格式说明符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12427886/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4