iOS 8.3

编程入门 行业动态 更新时间:2024-10-28 19:32:29
本文介绍了iOS 8.3-金属,展开一个可选值时发现为零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在Apple发布iOS 8.3之前,我的代码可以正常工作,但是由于更新的XCode抱怨找到了一个nil值,即使我的值都不为nil(我在调试时对此进行了验证).

Before Apple released iOS 8.3 my code worked, however since the updating XCode complains that a nil value is found, even though none of my values are nil (I validated this when debugging).

出于理智,我重新编写了程序,使用Metal渲染了一个简单的三角形到屏幕上,但是抛出了同样的错误.我有一个由3个顶点组成的数组,然后将其乘以数组的大小即可得到缓冲区的大小,并传入OptionCPUCacheModeDefault,因为我认为传递nil参数可能是导致问题的原因.

For sanity, I re-wrote my program to render a simple triangle to the screen with Metal, but the same error is thrown. I have an array of 3 vertices, I then multiply that by the array size to get the size of the buffer and pass in OptionCPUCacheModeDefault as I thought passing a nil parameter may have been what was causing my problem.

// Test array of vertices let ASVertices:[Float] = [ 0.0, 1.0, 0.0, -1.0, -1.0, 0.0, 1.0, -1.0, 0.0 ] // Other Metal init code... // Set the buffers let dataSize = ASVertices.count * sizeofValue(ASVertices[0]) vertexBuffer = ASDevice.newBufferWithBytes(ASVertices, length: dataSize, options: MTLResourceOptions.OptionCPUCacheModeDefault)

当我调试时,我可以看到dataSize是预期的36(9 * 4),所以我对为什么得到fatal error when unwrapping an optional value感到很困惑.我知道错误是不言自明的,但是上面打印的代码是堆栈跟踪显示正在引发的异常的地方,但是我看不到那里的nil值.是什么原因造成的?

When I debug, I can see that dataSize is 36 (9*4) as expected, so I am fairly stumped as to why I am getting a fatal error when unwrapping an optional value. I know that error is self explanatory but the code printed above is where the stack trace shows the exception being raised, but I see no nil values there. What could be causing this?

推荐答案

当连接到Xcode时,金属不能真正与iOS 8.3一起使用.现在,禁用GPU帧捕获,并提交雷达.

Metal doesn't really work with iOS 8.3, when connected to Xcode. For now, disable GPU Frame Capture, and file a radar.

更多推荐

iOS 8.3

本文发布于:2023-11-26 12:20:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1633910.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:iOS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!