xcode 5.1错误隐式转换失去精度

时间:2014-03-13 04:54:54

标签: cocoa core-plot

我更新到Xcode 5.1并且不能再构建几个使用Core Plot 1.4的项目,一般抱怨垃圾收集,并建议我转换为ARC。我遵守了,但有几个声明无法转换。我很快找到了解决方案,我在这里找到了一个很有希望的解决方案:

Core Plot and Xcode 5.1 - How to convert Core Plot to ARC?

我遵循了这个建议,它适用于转换为ARC。但是,我现在在CPTTextStylePlatformSpecific.m中留下了2个错误(不是警告),它抱怨:“隐式转换失去了整数精度:' NSTextAlignment' (又名'无符号长')到CPTTextAlignment' (又名' enum _CPTTextAlignment')“。在Xcode更新之前构建项目时没有出现此问题。

违规代码:

    // Text alignment and line break mode
NSParagraphStyle *paragraphStyle = [attributes valueForKey:NSParagraphStyleAttributeName];
if ( paragraphStyle ) {
    newStyle.textAlignment = paragraphStyle.alignment;
    newStyle.lineBreakMode = paragraphStyle.lineBreakMode;
}

return [[newStyle copy] autorelease];

在这里:

    // Text alignment and line break mode
NSParagraphStyle *paragraphStyle = [attributes valueForKey:NSParagraphStyleAttributeName];
if ( paragraphStyle ) {
    newStyle.textAlignment = paragraphStyle.alignment;
    newStyle.lineBreakMode = paragraphStyle.lineBreakMode;
}

return newStyle;

在这两种情况下,错误都在行

    newStyle.textAlignment = paragraphStyle.alignment;

我猜这个枚举是一个整数,而整数到长赋值是个问题。似乎它值得警告,而不是错误。是否有我可以设置的编译器标志来实现此目的?或者我错过了一个更大的问题?

1 个答案:

答案 0 :(得分:2)

我确实遇到了这个问题,并发现在CorePlot项目中,我已导入到我的项目中,我将“Apple LLVM 5.1 - 警告策略”,“将警告视为错误”设置为“是”。我仍然收到警告,但至少我可以建立并提交我的项目。 这仍然不理想,我真的想要一个合适的解决方案 - 我想我只需要继续检查CorePlot存储库的更新。

Warnings As Errors...