I\'ve got a strange problem with setter in swift. I\'ve got class PlayingCard with code:
var rank: NSInteger {
get{
return self.rank
}
se
By writing this...
set(suit) {
self.suit = suit
}
... you introduce an infinite loop, because you call the setter from within the setter.
If your property isn't computed, you should take advantage of willSet
and didSet
notifiers to perform any additional work before/after the property changes.
By the way, you should remove te getter as well. It will cause another infinite loop when accessing the property.