usbong / UsbongKit

A framework for reading and displaying contents of Usbong Trees
www.usbong.ph
Apache License 2.0
2 stars 1 forks source link

Converting UnicodeScalar to unichar #34

Closed masarapmabuhay closed 7 years ago

masarapmabuhay commented 7 years ago

Salut! I'm now slowing but surely squashing the bugs that have crept up in UsbongKit after I updated the code to Swift 3.

In NString+Words.swift, there is this line of code that produced an error:

let isWordCharacter = !nonWordCharacterSet.contains(UnicodeScalar(char))

I then modified contains to characterIsMember.

let isWordCharacter = !nonWordCharacterSet.characterIsMember(UnicodeScalar(char))

The issue the compiler is complaining about now is...

cannot convert value of type 'UnicodeScalar?' to expected argument type 'unichar'...

I hope you can provide guidance on how I may be able to resolve this issue!

Merci beaucoup!

p.s. I finished the "Swift Programming Syntax" course at udacity.com, and am now using it as a reference, e.g. on the topic about "optionals".

masarapmabuhay commented 7 years ago

Salut! It seems that I was able to resolve this issue by doing the following.

let isWordCharacter = !nonWordCharacterSet.characterIsMember(UniChar((UnicodeScalar(char)?.value)!))

It seems so roundabout with all the optionals, but perhaps it is for the best, because I have not yet fully grasped how you implemented UsbongKit (iOS) as well as Swift 3.

Merci beaucoup!