在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
发布评论