2

我已将我的 Xcode 版本从 5.0 升级到 5.1 并开始在 GPUImage 库 GPUImageVideoCamera.m:301:54 中出现以下错误:隐式转换失去整数精度:'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

        }
    }
}

在此处输入图像描述

4

1 回答 1

9

问题与architecture. 如果您在 Xcode 5.1 中打开现有项目,它的默认架构设置是 64 位架构。

请参阅Xcode 5.1 release nots中的这一行

注意:在 Xcode 5.1 中打开现有项目时,请注意以下架构问题:

  • 为所有架构构建时,删除任何显式架构设置并使用默认的标准架构设置。对于之前选择使用“包括 64 位的标准架构”的项目,切换回“标准架构”设置。
  • 首次打开现有项目时,Xcode 5.1 可能会显示有关使用 Xcode 5.0 架构设置的警告。选择警告提供了修改设置的工作流程。
  • 无法支持 64 位的项目需要专门设置架构构建设置以不包括 64 位。

您可以在这个苹果的文档中看到这一行。

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
);
于 2014-03-14T06:13:06.220 回答