iOS 8.3 - Metal, found nil while unwrapping an Optional Value

荒凉一梦 提交于 2020-01-15 03:21:07

问题


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).

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)

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?


回答1:


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



来源:https://stackoverflow.com/questions/29584463/ios-8-3-metal-found-nil-while-unwrapping-an-optional-value

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!