【发布时间】:2023-03-24 11:07:01
【问题描述】:
在迁移到 Swift 时,我将 Objective-C sn-p 转换为 Swift。我还是 Objective-C 的新手,我对 Swift 的了解也很一般。满足参数 C char 尝试从 Int8 转换为 C 字符时遇到问题。
class func computeSHA256Digest(for input: String?) -> String? {
let cstr = Int8(input?.cString(using: .utf8) ?? 0)
/* the rest of code */
}
无法将“Int”类型的值转换为预期的参数类型“[CChar]”(又名数组)
【问题讨论】:
-
[CChar]是一个数组,所以不能将 Int 转换为数组