Swift를 C나 C++과 연동해 사용하게 될경우 (Int8,Int8,Int8,….Int8)을 문자열로 변환 해야 하는 상황이 발생
struct record
{
char name[8];
};
다음 c소스를 swift에서 문자열로 받기 위한 코드임
let name = withUnsafePointer(to: record.name) {
$0.withMemoryRebound(to: UInt8.self,
capacity: MemoryLayout.size(ofValue: $0)) {
String(cString: $0)
}
}