繁体   English   中英

Swift 无法更新 ParseConfiguration

[英]Swift cannot update ParseConfiguration

请参阅此 swift 操场:

https://github.com/parse-community/Parse-Swift/blob/main/ParseSwift.playground/Pages/14%20-%20Config.xcplaygroundpage/Contents.swift

 //: Create a value typed `ParseConfig` that matches your server config.
enter code here

struct Config: ParseConfig {

//: If your server Config has any parameters their names and types should
//: match your ParseCondig properties:
var welcomeMessage: String?
var winningNumber: Int?
}
/*: Go to your Parse Dashboard and click `Config->Create a parameter`:
Now add the following parameters:
 - Parameter Name: "welcomeMessage", Type: "String", Value: "Hello".
 - Parameter Name: "winningNumber", Type: "Number", Value: "42".



*/
var config = Config()

config.fetch { result in
    switch result {
    case .success(let currentConfig):
        print("The current config on the server: \(currentConfig)")
    case .failure(let error):
        assertionFailure("Error fetching the config: \(error)")
    }
}

//: We can also update the config.
config.winningNumber = 50

//: Save the update.
config.save { result in
    switch result {
    case .success(let isUpdated):
        if isUpdated {
            print("The current config on the server has been updated.")
        } else {
            print("The current config on the server failed to update.")
        }
    case .failure(let error):
        assertionFailure("Error updating the config: \(error)")
    }
}

仅在更新时提取工作正常我收到一条错误消息:

ParseError code=-1 error=Invalid struct: No value associated with key CodingKeys(stringValue: "result", intValue: nil) ("result").

谢谢

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM