An instance method makeVerticesUnique()
modified the mesh’s vertex buffers so that no vertices were shared by multiple faces. But it was deprecated in macOS 10.13 High Sierra and in iOS 11:
mdlMesh.makeVerticesUnique() /* deprecated in macOS 10.13 and iOS 11 */
Now developers must use a new instance method:
func makeVerticesUniqueAndReturnError() throws
But it's not documented. How to use it?
When I'm using this new instance method Xcode gives me an error:
'throws' may only occur before '->'
Whenever you don't find docs on developer.apple.com or in the Xcode Documentation Viewer, check the framework headers or Swift interface — those often have code comments that can at least serve as a rough form of documentation.
In Xcode, use Open Quickly (⌘⇧O) and type the name of the header in question (
MDLMesh.h
) or one of the symbols inside it (MDLMesh, makeVerticesUnique, etc
). Or ⌘-click one of those symbols in your source and choose Jump to Definition. (If at that point you end up in an Objective-C header and want to see the Swift version, choose Generated Interface from the related items menu at the top of the file.)In this case, you'll see that both methods are equivalent in usage (but for the ability of the new method to throw errors):
Presumably Apple determined that the original method wasn't handling failures gracefully (fatal-error halting? crashing? producing bad output? dunno) and decided it'd be better to let callers know when something goes wrong.