Creates a library object containing the functions stored in a binary data object created from a precompiled Metal library.
Required.
SDKs
- iOS 8.0+
- macOS 10.11+
- Mac Catalyst 13.0+
- tvOS 9.0+
Framework
- Metal
Declaration
- (id<MTLLibrary>)newLibraryWithData:(dispatch _data _t)data error:(NSError * _Nullable *)error;
Parameters
data
The data from a precompiled Metal library. For more information, see Creating Libraries During the App Build Process.
error
An error object that describes the problem, or
nil
if the operation succeeded.
Return Value
A new library object that contains the functions from the metallib
file.
Discussion
Use this method if your application manages its own archiving system for libraries—for example, if you have a single file that contains several libraries.
Handling Errors in Swift:
In Swift, this method returns a nonoptional result and is marked with the throws
keyword to indicate that it throws an error in cases of failure.
You call this method in a try
expression and handle any errors in the catch
clauses of a do
statement, as described in Error Handling in The Swift Programming Language and About Imported Cocoa Error Parameters.