Open griffinTao opened 7 months ago
class HueSaturation: NSObject, NSSecureCoding, NSCopying {
static var supportsSecureCoding: Bool = true
var hue: Double = 0
var saturation: Double = 0
override init() {
super.init()
}
init(hue: Double, saturation: Double) {
self.hue = hue
self.saturation = saturation
super.init()
}
required init?(coder aDecoder: NSCoder) {
self.hue = aDecoder.decodeDouble(forKey: "hue")
self.saturation = aDecoder.decodeDouble(forKey: "saturation")
super.init()
}
func encode(with aCoder: NSCoder) {
aCoder.encode(hue, forKey: "hue")
aCoder.encode(saturation, forKey: "saturation")
}
func copy(with zone: NSZone? = nil) -> Any {
let newInstance = HueSaturation(hue: self.hue, saturation: self.saturation)
return newInstance
}
func interpolateBetween(rightValue: NSSecureCoding & NSCopying, withWeight weight: Float) -> NSSecureCoding & NSCopying {
let result = HueSaturation(hue: self.hue, saturation: self.saturation)
return result
}
func isEqual(to object: NSSecureCoding & NSCopying) -> Bool {
guard let rhs = object as? HueSaturation else { return false }
return self.hue == rhs.hue && self.saturation == rhs.saturation
}
}
这个是代码,我把使用FxParameterRetrievalAPI_v6 -getCustomParameterValue部分给删除掉了,因为我更喜欢在外部调用getCustomParameterValue,稍后我会给出一个示例
let paramAPI = _apiManager!.api(for: FxParameterRetrievalAPI_v6.self) as! FxParameterRetrievalAPI_v6
var temColorManagementData: (any NSCopying & NSSecureCoding & NSObjectProtocol)? = nil
paramAPI.getCustomParameterValue(&temColorManagementData, fromParameter: ParamsId.colorManagement.rawValue, at: renderTime)
let newColorManagementData = temColorManagementData as! ColorManagementParams
这是一个使用示例,希望能对你有帮助
我的e-mail是2281060984@qq.com,有咨询可以发送我的邮箱
对了,这个示例并没有提供如何传递String或者[Float]类型,因为项目本身并不包含,如果需要的话,可以询问我,目前我也只有这两种方式的示例
I am use Chinese, maybe you need translate
Because NSObject, NSSecureCoding, and NSCopying have conflicting function definitions in their protocols. Swift doesn't allow that but Objective-C does. Ideally there would be a very small Objective-C layer in this framework that handles just the incompatible parts, but I haven't gotten to that.
抱歉,我的工作更多是Python与Javascript,我并不是一个专业的apple开发者,没有办法给你提供帮助🌹
HueSaturation.m
Why this file use Object-C,Why not use Swift