Export and use Create ML model in runtime

Hello!

In my iPhone app, I have created a button so that I can retrain my CreateML Linear Regression:

let model = try MLLinearRegressor.init(trainingData: trainingData.base, targetColumn: "Target")

Now I want to use this model in the UI. I know that I can use the model above directly, like following:

let pred = try model.predictions(from: testData)

However, I prefer using .mlmodel files, because I want to receive one prediction at a time, instead of having to input a DataFrame.

I have seen examples where people use the model.write-method to store the .mlmodel on the computer desktop for example, but I want to do it in runtime in the app. Is this possible? And in that case, how can I store the .mlfile and load it again? Can I do it in the app repository?