2022-07-01から1ヶ月間の記事一覧

Dictionaryのキー存在しない時デフォルトバリューを提供する

let dic = ["dog": 1, "cat": 2] print(dic["chicken", default: 0]) // outputは0

SwiftのDataをKotlinのByteArrayに変換

KMM

extension Data { func toKotlinByteArray() -> KotlinByteArray { let byteArray = [UInt8](self) let kotlinByteArray = KotlinByteArray(size: Int32(byteArray.count)) for (i, byte) in byteArray.enumerated() { kotlinByteArray.set(index: Int32(i),…