iphone - “NSString”可能无法响应 '-hexIntValue' 警告,功能正常

标签 iphone objective-c iphone-sdk-3.0

我正在获取作为字符串接收的十六进制颜色值并将其转换为 int,以便我可以获得正确的十六进制值。我的导入下面有以下代码:

@implementation NSString (HexIntValue)

- (unsigned int)hexIntValue
{

    NSScanner *scanner;
    unsigned int result;

    scanner = [NSScanner scannerWithString: self];  
    [scanner scanHexInt: &result];

    return result;

}

@end

然后在此处对字符串调用该函数:

unsigned int x = (int)[globalBGColor hexIntValue];

一切正常,但我真的想摆脱警告,因为我或多或少准备提交我的应用程序。

谢谢!

最佳答案

我会把你的类别扔到另一个文件中。约定将其命名为“NSSting+HexIntValue.h”。然后确保#import它。应该清除一切。

关于iphone - “NSString”可能无法响应 '-hexIntValue' 警告,功能正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3162033/

相关文章:

iphone - 是否可以在 Objective C 中创建 CLHeading 对象?

iphone - 我的服务器如何安全地验证 iPhone 应用内购买?

iphone - UITextView 文字渗色效果

iPhone 头脑 Storm - CLLocation 在后台 - 每 15 分钟轮询一次

iphone - 如何在退出时轻松保持应用程序状态

objective-c - 如何在 objective-c 中找到鼠标的位置

ios - NSUserDefaults 或存储大型数组时的其他内容?

ios - 如何在 NSURLRequest 中附加 TLS/SSL 证书?

iphone - 从应用程序和电子邮件中检索保存的图像

ios - 如何检查用户之前是否在 iOS 中看到过推送通知权限警报 View ?