ios - Error when using .capitalized (Swift 3) -


i have simple question on property .capitalized in swift 3. here piece of code:

var pinkman = "yo yo yo mr white" var capitalizeit = pinkman.capitalized print(capitalizeit) 

it gives me following error:

value of type 'string' has no member 'capitalized'

any help?

thanks in advance!

edit: looks works, have no idea why getting error in beginning.

assuming you're using xcode 8..

in build settings, use legacy swift version set yes? in case, it'd compiling swift 2.3. if no, it'll compiling swift 3.

swift 2.3 doesn't have .capitalized, it's .capitalizedstring, 3.0 onwards it's former.

furthermore, importing @ least foundation? if not, uikit, appkit, cocoa fine automatically import foundation.

finally, swift file you've created part of objective-c project? or part of swift project?


Comments