This question asks whether one can use subscripting with CKRecord
in Swift. While I already knew how to do what the questioner wanted, every permutation of it g
After some testing and debugging (via a subclass), I discovered that, for CKRecord
, objectForKey:
does indeed call objectForKeyedSubscript:
. Also, implementing subscript
in a Swift class that is marked @objc
implicitly (by descending from NSObject
) or explicitly means that subscript
is implemented as objectForKeyedSubscript:
.
This means that implementing subscript
on CKRecord
in an extension hides the default implementation, which causes the stack overflow.