If I attempt to run the following code:
photographer = photographer
I get the error:
Assigning a property to itself
@vacawama did a great job with all those options. However in iOS 10.3, Apple banned some of these ways and most likely will be doing it in the future again.
Note: To avoid the risk and future errors, I will use a temporary variable.
func callSet(_ object: inout T) {
let temporaryObject = object
object = temporaryObject
}
Would be used like: callSet(&foo)
prefix operator +=
prefix func +=(_ object: inout T) {
let temporaryObject = object
object = temporaryObject
}
Would be used like: +=foo