How does NSData(bytes:length:) convert [Byte] to UnsafePointer<Void> in Swift?
问题 Playing with raw data in Swift I came across something I don't understand. NSData has a constructor: init(bytes: UnsafePointer<Void>, length: Int) where the first bytes parameter is clearly of UnsafePointer type. However, if I pass [Byte] object to this constructor, not only does the compiler not complain, but it works ok. But if I try to cast [Byte] to UnsafePointer , I fail. How does this work? For example (you can try it in Playgrounds): let buffer: [Byte] = [0x00, 0xff] let data = NSData