Skip to content

Instantly share code, notes, and snippets.

@stuffmc
Last active August 29, 2015 14:06
Show Gist options
  • Save stuffmc/b03c2cb55b8084cac985 to your computer and use it in GitHub Desktop.
Save stuffmc/b03c2cb55b8084cac985 to your computer and use it in GitHub Desktop.
func simulate(hexa: Int!) -> NSData! {
let string = NSString.stringWithCharacters([0x01], length: 1) // Totally compiles
func simulate(hexa: Int!) -> NSData! {
let string = NSString.stringWithCharacters([hexa], length: 1)
// Compile error: 'UnsafePointer<unichar>' does not have a member named 'Element'
FIX:
func simulate(hexa: unichar) -> NSData! {
@tammofreese
Copy link

unichar(hexa) will blow up if hexa is too big to fit in an unichar. Better make the function accept unichar only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment