I have a class called Letter
class Letter
{
init() {}
}
And I have an extension for this class:
extension Letter
{
convenience init(file_path:String) {
self = Letter.loadFromFile(file_path)
}
class func loadFromFile(file_path:String)->Letter {...}
}
I need to create and init with path to file and when i call Letter(file_path)
I need a new object that returned by a func loadFromFile
. How to assign in an init method or to return a new object?
It gives the error:
Cannot assign to value: 'self' is immutable