Dat*_*kar 2 objective-c ios gpuimage xcode5.1
我已将我的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
}
}
}
Run Code Online (Sandbox Code Playgroud)

问题与此有关architecture.如果您在Xcode 5.1中打开现有项目,它的默认arch设置是64位体系结构.
请参阅Xcode 5.1发行版中的这一行
注意:在Xcode 5.1中打开现有项目时,请注意以下体系结构问题:
你可以在这个苹果的文档中看到这一行.
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);
Run Code Online (Sandbox Code Playgroud)
请参阅CMTimeMake语法.
CMTime CMTimeMake (
int64_t value,
int32_t timescale
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17643 次 |
| 最近记录: |