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

标签 cocoa core-plot

我更新到了 Xcode 5.1,无法再构建几个使用 Core Plot 1.4 的项目,普遍提示垃圾收集,并建议我转换为 ARC。我答应了,但是有几个语句无法转换。我很快就来到SO寻找解决方案,并在这里找到了一个有前途的解决方案:

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

我遵循了这个建议,并且它对转换为 ARC 有效。然而,我现在在 CPTTextStylePlatformSpecific.m 中留下了 2 个错误(不是警告),它提示:“隐式转换丢失了整数精度:'NSTextAlignment'(又名'unsigned long')到'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;

我猜测枚举是一个整数,而整数到长赋值就是问题所在。似乎值得警告,而不是错误。我可以设置编译器标志来实现此目的吗?或者我遗漏了一个更大的问题?

最佳答案

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

Warnings As Errors...

关于cocoa - xcode 5.1错误隐式转换失去精度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22369372/

相关文章:

swift - 使用 Swift 检测 MacBook 盖子的打开/关闭?

objective-c - 在 Objective-C 中选择 NSArray 的随机元素

ios - 如何在 iOS 中描绘雷达图?

ios - 使用 Core Plot 库在 IOS 中绘制 ECG。

ios - OBJ-C : Core-Plot XY-Axis Fixing

ios - 快速图表

iphone - 什么时候不需要为 Nib 指定文件所有者?

objective-c - 如何避免在动画(completionBlock)和非动画代码之间出现重复代码

objective-c - 如何对 NSArrayController (子类)进行单元测试?

ios - 在商业应用程序的 iOS 中使用 CorePlot 是否有任何限制?