【发布时间】:2013-08-09 23:09:05
【问题描述】:
我想知道为什么会出现此错误:
ARC 不允许将“int”隐式转换为“id”
self.versionButton.titleLabel.font = [UIFont fontWithName:@"AdobeClean-Light" size:self.versionButton.titleLabel.font.pointSize]; <- Implicit conversion of 'int' to 'id' is disallowed with ARC
查看 UIFont 的头文件,我看到 'fontWithName' 想要一个 CGFloat
+ (UIFont *)fontWithName:(NSString *)fontName size:(CGFloat)fontSize
{
return [self fontWithNSFont:[NSFont fontWithName:fontName size:fontSize]];
}
查看 UIFont 的头文件,我看到 'pointSize' 返回一个 CGFloat
- (CGFloat)pointSize
{
return CTFontGetSize(_font);
}
我正在导入导入“UIFont.h”的 UIKit
【问题讨论】:
-
实际上,看看那一行,很难看出这个特定的错误是如何引发的。我猜 Xcode 可能突出显示了错误的行之类的。
-
(您是否忽略了任何警告?)
-
我怀疑问题出在其他地方,因为该行在这里编译并运行良好。
-
嗯...考虑到他们有
UIFont的源代码,这一定是使用了一个为OSX 包装了UIKit 的库。也许有一个导入警告,Xcode 推断出int的类型返回类型。 -
@user2665402:如果您找到了问题的解决方案,那么您可以将其发布为答案,这样未来的读者就不必阅读所有 cmets。
标签: objective-c