我正在构建一个插件来使用iOS设备中的星形打印机,使用它们的SDK,一切正常,但config-file修改info.plist文件的命令无法正常工作.在我的plugin.xml里面,我有:
<config-file target="*-Info.plist" parent="Supported external accessory protocols">
<array>
<key>item 0</key>
<string>jp.star-m.starpro</string>
</array>
</config-file>
Run Code Online (Sandbox Code Playgroud)
有了这个我应该得到一个Supported external accessory protocols数组,其中包含一个名为item 0,类型String和值的项目,jp.star-m.starpro但我得到一个包含两个项目的数组,就好像我会做的那样:
<array>
<key>item 0</key>
<string>item 0</string>
<key>item 1</key>
<string>jp.star-m.starpro</string>
</array>
Run Code Online (Sandbox Code Playgroud)
相关问题:
我config-file通过阅读这些问题来实现.
我需要Decodable正确解码(协议)一个不精确的十进制值,从这个问题我了解如何正确处理十进制实例化,但是在解码时如何做到这一点?
如果尝试将任何数字初始化为字符串
if let value = try! container.decode(String.self, forKey: .d) {
self.taxAmount = Decimal(string: value)
}
Run Code Online (Sandbox Code Playgroud)
我明白了Fatal Error: "Expected to decode String but found a number instead."
如果尝试将 130.43 初始化为十进制
if let value = try! container.decode(Decimal.self, forKey: .d) {
//value.description is 130.43000000000002048
self.d = Decimal(string: value.description)
//making subtotal to be also 130.43000000000002048 and not 130.43
}
Run Code Online (Sandbox Code Playgroud)
解码时有什么方法可以使用这个构造函数吗?
NSDecimalNumber(string: "1.66")NSDecimalNumber(value: 166).dividing(by: 100)Decimal(166)/Decimal(100)Decimal(sign: .plus, exponent: -2, significand: 166)以下是我从外部服务收到的 JSON 的简化版本:
{
"priceAfterTax": 150.00, …Run Code Online (Sandbox Code Playgroud)