---
title: "init(contentsOf:)"
framework: coreml
role: symbol
role_heading: Initializer
path: "coreml/mlmodel/init(contentsof:)"
---

# init(contentsOf:)

Creates a Core ML model instance from a compiled model file.

## Declaration

```swift
convenience init(contentsOf url: URL) throws
```

## Parameters

- `url`: The path to a compiled model file (ModelName.mlmodelc), typically with the URL that doc://com.apple.coreml/documentation/CoreML/MLModel/compileModel(at:)-6442s returns.

## Discussion

Discussion In most cases, your app won’t need to create a model object directly. Consider the programmer-friendly wrapper class that Xcode automatically generates when you add a model to your project (see Integrating a Core ML Model into Your App). If the wrapper class doesn’t meet your app’s needs or you need to customize the model’s configuration, use this initializer to create a model object from any compiled model file you can access. Typically, you use this initializer after your app has downloaded and compiled a model, which is one technique for saving space in your app (see Downloading and Compiling a Model on the User’s Device).

## See Also

### Loading a model

- [load(contentsOf:configuration:)](coreml/mlmodel/load(contentsof:configuration:).md)
- [load(_:configuration:completionHandler:)](coreml/mlmodel/load(_:configuration:completionhandler:).md)
- [load(contentsOf:configuration:completionHandler:)](coreml/mlmodel/load(contentsof:configuration:completionhandler:).md)
- [init(contentsOf:configuration:)](coreml/mlmodel/init(contentsof:configuration:).md)
- [init(contentsOfURL:)](coreml/mlmodel/init(contentsofurl:).md)
- [init(contentsOfURL:configuration:)](coreml/mlmodel/init(contentsofurl:configuration:).md)
