let renderEncoderOpt = commandBuffer.renderCommandEncoderWithDescriptor(renderPassDescriptor)
if let renderEncoder = renderEncoderOpt {
renderEncoder.setRenderPipelineState(pipelineState)
renderEncoder.setVertexBuffer(vertexBuffer, offset: 0, atIndex: 0)
renderEncoder.drawPrimitives(.Triangle, vertexStart: 0, vertexCount: 3, instanceCount: 1)
renderEncoder.endEncoding()
}
The code above throws an
Initializer for conditional binding must have Optional type, not 'MTLRenderCommandEncoder'
If i try and make renderEncoderOpt an optional though, the issue still remains. I've tried testing with guard let vs if let, and tried setting it to optionals, and redeclaring type etc, but it keeps coming back to this issue. This worked ok in swift 1/1.2
Does anyone have an pointers?