Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
swift 3中的字典值始终为零_Swift_Dictionary - Fatal编程技术网

swift 3中的字典值始终为零

swift 3中的字典值始终为零,swift,dictionary,Swift,Dictionary,我有一本这样的字典 ["Success": 1, "ControlId": <null>, "Message": Record has been saved, "MessageId": Record has been saved, "Source": <null>, "Result": 193, "ErrorCode": 0, "Description": <null>] if let success=self.dm.responseDict["Succes

我有一本这样的字典

["Success": 1, "ControlId": <null>, "Message": Record has been saved, "MessageId": Record has been saved, "Source": <null>, "Result": 193, "ErrorCode": 0, "Description": <null>]
if let success=self.dm.responseDict["Success"] as? Int
{
    if (success==1)
    {
        callback(true)
    }
    else
    {
        if let errmsg=self.dm.responseDict["Message"] as? String
        {
            self.strErrorMessage=errmsg
        }
        callback(false)
    }
}

但我的问题是,
成功
总是为零,并且不满足条件。出现这种情况的原因是什么?我如何以正确的方式检查它?

如果
成功
则您的
as中存在错误?Int
假设您的字典如下所示:

["Success": 1, "ControlId": <null>, "Message": Record has been saved, "MessageId": Record has been saved, "Source": <null>, "Result": 193, "ErrorCode": 0, "Description": <null>]
“Success”键的值可能是
Bool
而不是
Int
if let success = success=self.dm.responseDict["Success"] as? Bool {
    if success {
        callback(true)
    } else {
        if let errmsg=self.dm.responseDict["Message"] as? String {
            self.strErrorMessage=errmsg
        }
        callback(false)
    }
}