I am new to Swift and would like to initialize an object\'s member variable using an instance method like this:
class MyClass {
var x: String
var y: Stri
I think the Swift way to do this is with Computed Properties (https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Properties.html)
EDIT
Instead of calling a function to modify a property on set/get, you can use computed properties:
class MyClass {
var x: String?
var y: String? {
get {
return "\(x!)_test"
}
}
init(x: String!){
self.x = x
}
}
let myClass = MyClass(x: "string")
print(myClass.y!) #=> "string_test"