0
A
回答
4
試試這個
let u8: [UInt8] = [0x02, 0x02, 0x02]
let u32: [UInt32] = u8.map { UInt32($0) }
print("u32: \(u32)")
+0
爲什麼你要調用32位整數'u16'的數組? - 不需要類型註釋'[UInt32]'。 –
+0
@MartinR這是一個錯字。是。類型註釋'[UInt32]'不需要。 –
相關問題
- 1. swift將UInt32拆分爲[UInt8]
- 2. 如何將UInt16轉換爲Swift 3中的UInt8?
- 3. 轉換字節到UINT8(SWIFT 3)
- 4. 在Swift中將Int轉換爲UInt32
- 5. 在Swift 3中將NSData轉換爲NSString?
- 6. 在[swift]中將[AnyObject]轉換爲[Int] 3
- 7. 轉換爲Swift 3
- 8. 如何在Go中將uint8轉換爲uint32?
- 9. Swift 3轉換
- 10. Swift 3:將空終止的UnsafePointer <UInt8>轉換爲字符串
- 11. 將Swift 3數組轉換爲JSON
- 12. 將字符轉換爲int - swift 3
- 13. 將UIView轉換爲UIImage Swift 3
- 14. Swift 3將Double轉換爲字符串
- 15. 將Objective-C語法轉換爲Swift 3
- 16. Swift 3:如何將[String:AnyObject]轉換爲[String:String]?
- 17. 如何將URL轉換爲NSImage(Swift 3)
- 18. 將C#JSON POST轉換爲SWIFT 3
- 19. 將字符串轉換爲NSObject Swift 3
- 20. 如何將Swift 2中的Singleton類轉換爲Swift 3?
- 21. 將int轉換爲UINT32
- 22. 鑄造UINT8 UINT32到
- 23. 如何將元素從Swift中的[UnsafeMutablePointer <UInt8>]轉換爲C++中的UInt8 *
- 24. 將ASCII轉換爲uint8
- 25. 如何在Swift 3中將__NSMallocBlock__轉換爲其基礎類型?
- 26. 如何在Swift 3中將字符串從TextField轉換爲Int?
- 27. 在Swift 3中,如何將字典轉換爲Object?
- 28. 如何在Swift 3中將數據轉換爲Int?
- 29. 將[] uint8轉換爲float64
- 30. iOS應用程序在轉換爲Swift 3後未啓動3
你嘗試過什麼? 'UInt32'可以用'UInt8'初始化。你是否在尋找比將這個數組映射到最後一個更復雜的東西? – Losiowaty
請參閱https://stackoverflow.com/questions/25267089/convert-a-two-byte-uint8-array-to-a-uint16-in-swift –
'let u32 = u8.map {UInt32($ 0)}'或者你想要'[UInt8]'到'UInt32'(沒有數組)? – vadian