苹果为什么能做到这一点:
import CoreGraphics
import GameplayKit
import simd
/**
@header
SceneKit framework category additions related to GameplayKit integration.
@copyright 2017 Apple, Inc. All rights reserve.
*/
extension SCNNode {
/**
* The GKEntity associated with the node via a GKSCNNodeComponent.
*
* @see GKEntity
*/
@available(OSX 10.13, *)
weak open var entity: GKEntity?
}
/**
* Adds conformance to GKSceneRootNodeType for usage as rootNode of GKScene
*/
extension SCNScene : GKSceneRootNodeType {
}
...我不能这样做:
extension SCNNode {
weak open var ntity: GKEntity?
}
并得到两个错误:
- 'weak' 只能应用于类和类绑定协议类型,而不是 '<<error type>>'
- 扩展可能不包含存储的属性
我真正想做的是在 10.13 之前的 OSX 版本上提供实体属性,因此也欢迎对此提出其他建议。