2014-03-14 32 views
2

我已将5.0版本的Xcode版本升级到5.1 & GPUImage Library中出现错误 GPUImageVideoCamera.m:301:54:隐式转换失去整数精度: 'NSInteger的'(亦称 '长'),以 'int32_t'(又名 'INT')值转换问题:隐式转换失去整数精度:'NSInteger'(又名'long')为'int32_t'(又名'int')

在关于这条线之下函数“connection.videoMaxFrameDuration = CMTimeMake (1,_frameRate);“错误正在发生。

- (void)setFrameRate:(NSInteger)frameRate; 
{ 

    _frameRate = frameRate; 

    if (_frameRate > 0) 
    { 

     for (AVCaptureConnection *connection in videoOutput.connections) 
     { 

      if ([connection respondsToSelector:@selector(setVideoMinFrameDuration:)]) 

       connection.videoMinFrameDuration = CMTimeMake(1, _frameRate); 

      if ([connection respondsToSelector:@selector(setVideoMaxFrameDuration:)]) 

       connection.videoMaxFrameDuration = CMTimeMake(1, _frameRate); 

     } 
    } 

    else 

    { 
     for (AVCaptureConnection *connection in videoOutput.connections) 

     { 
      if ([connection respondsToSelector:@selector(setVideoMinFrameDuration:)]) 

       connection.videoMinFrameDuration = kCMTimeInvalid; 
           // This sets videoMinFrameDuration back to default 

      if ([connection respondsToSelector:@selector(setVideoMaxFrameDuration:)]) 

       connection.videoMaxFrameDuration = kCMTimeInvalid; 
           // This sets videoMaxFrameDuration back to default 

     } 
    } 
} 

enter image description here

+0

在Xcode 5.1中,默认情况下启用了64位体系结构。这不应该是一个错误,而只是一个警告。要摆脱警告,您可以添加显式强制转换或更新库。 – carloabelli

+1

Xcode将其视为错误 –

+1

@DattatrayDeokar:也许您已将生成设置“将警告视为错误”设置为YES。 - 如上面的评论所述,只需添加一个明确的强制转换,或将_frameRate的类型从NSInteger更改为int。 –

回答

9

问题与architecture有关。如果您在Xcode 5.1中打开现有项目,则默认的arch设置是64位体系结构。

Xcode 5.1 release nots

注意此行:

  • 当建立对所有架构,删除任何:在Xcode 5.1打开你 现有项目时,要注意以下结构问题明确的 体系结构设置并使用默认的标准体系结构 设置。对于之前使用“标准 体系结构包括64位”加入的项目,切换回“标准 体系结构”设置。
  • 第一次打开现有项目时,Xcode 5.1可能会在 显示关于使用Xcode 5.0体系结构 设置的警告。选择警告提供了修改 设置的工作流程。
  • 无法支持64位的项目需要专门设置 体系结构构建设置为不包含64位。

您可以在this apple's doc中看到此行。

NSInteger以64位代码更改大小。整个Cocoa Touch中使用的NSInteger类型为 ;它是32位运行时间中的32位整数,在64位运行时中为64位整数。因此,当从采用NSInteger类型的框架方法接收到 信息时,请使用NSInteger类型的 来保存结果。

int is a 32-bit integer,所以只有这个出现这个错误。您可以通过将体系结构设置为standard architecture including 64-bit或执行简单类型转换来解决此问题,如下所示。

connection.videoMinFrameDuration = CMTimeMake((int64_t)1, (int32_t)_frameRate); 

请参阅CMTimeMake语法。

CMTime CMTimeMake (
    int64_t value, 
    int32_t timescale 
); 
+0

当前设置与您建议的标准体系结构相同,包括64位 –

+0

Mani可能意味着*从体系结构中排除* 64位。但是没有必要这样做,因为这个问题很容易通过明确的转换或数据类型的改变来解决。 –

+0

@MartinR是的。你是对的。我错过了我的回答 – Mani

相关问题