user1822451
user1822451

Reputation: 111

Swift 3 / Xcode 9. MTLBuffer 'didModifyRange' is unavailable

I'm trying to tell a MTLBuffer that the range has changed but the compiler won't let me do that:

vertexBuffer?.didModifyRange(NSMakeRange(0,MemoryLayout<MetalVertex>.stride*nbVerts))

it just says: 'didModifyRange' is unavailable why is that?

thanks

Upvotes: 0

Views: 181

Answers (2)

Tim Sylvester
Tim Sylvester

Reputation: 23138

Are you targeting iOS? Per the Apple Documentation, didModifyRange is only supported on macOS and Catalyst. It also only applies to buffers created with MTLStorageModeManaged, which has the same constraints.

If you're targeting multiple platforms, you will need to make both conditional, see:

Swift availability check for macCatalyst

Upvotes: 0

rickster
rickster

Reputation: 126127

In Swift, didModifyRange takes a Range<Int>, not an NSRange. So instead of using NSMakeRange, you can construct one using the ..< operator.

vertexBuffer?.didModifyRange(0 ..< MemoryLayout<MetalVertex>.stride * nbVerts)

Upvotes: 1

Related Questions