let asset = MDLAsset()
asset.add(mdlMesh)
/// 2
let fileExtension = "obj"
guard MDLAsset.canExportFileExtension(fileExtension) else {
fatalError("Can't export a .\(fileExtension)")
}
/// 3
do {
let url = playgroundSharedDataDirectory.appendingPathComponent("primitive.\(fileExtension)")
// let url = URL(string: "/Users/thomascurley/Documents/primitive.\(fileExtension)")!
print(url)
try asset.export(to: url)
}
catch {
fatalError("Error \(error.localizedDescription)")
}
Hello, I’ve copied this code from the book, however, when I try to execute this I get an exception thrown:
Fatal error: Error The operation couldn’t be completed. (Foundation._GenericObjCError error 0.): file Chapter1.playground, line 40
I have made a directory in
~/Documents/Shared Playground Data
However, when I print the URL the location isn’t the same:
file:///Users/thomascurley/Library/Developer/XCPGDevices/D9EB2BCE-ABB8-4571-8B6B-7ACCC0BE32EE/data/Containers/Data/Application/73982C04-BFA7-4898-A34F-9228D722B767/Documents/Shared%20Playground%20Data/primitive.obj
How do I fix this,
many thanks
I’m really enjoying this book!!!