无法推断通用参数 S

Generic parameter S could not be inferred

无法推断通用参数 S。

 var buff:[Int8] = [Int8](repeating:0,count:16)
 ...
 var addr = String(bytes: buff, encoding: String.Encoding.utf8)

How it seems in xCode

根据 the documentationbuff 需要是类型 S,其中 S : Sequence, S.Iterator.Element == UInt8。所以你需要它是一个 UInt8 的数组而不是 Int8 的

import Foundation

var buff:[UInt8] = [UInt8](repeating:0,count:16)
var addr = String(bytes: buff, encoding: .utf8)