更新时间:2022-06-06 21:40:51
经过一些测试和调试(通过子类)后,我发现对于 CKRecord
, objectForKey:
确实调用了 objectForKeyedSubscript:
。另外,在隐式标记为 @objc
的Swift类中实现下标
(通过从降级) NSObject
)或明确表示下标
被实现为 objectForKeyedSubscript:
。
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:
.
这意味着在扩展中的 CKRecord
上实现下标
实现,这会导致堆栈溢出。
This means that implementing subscript
on CKRecord
in an extension hides the default implementation, which causes the stack overflow.