Swift .uppercaseString or .lowercaseString property replacement -



Swift .uppercaseString or .lowercaseString property replacement -

since strings in swift no longer have .uppercasestring or .lowercasestring properties available, how go performing function?

if have example:

var sillystring = "this string!" allow yellystring = sillystring.uppercasestring allow silentstring = sillystring.lowercasestring

i take sillystring , mutate either uppercase or lowercase. how go doing now?

thanks in advance!

xcode 6.0 / swift 1.0

string bridged seamlessly nsstring, does have uppercasestring , lowercasestring properties as long import foundation (or framework since they'll import foundation internally. strings , characters section of swift programming guide:

swift’s string type bridged seamlessly foundation’s nsstring class. if working foundation framework in cocoa or cocoa touch, entire nsstring api available phone call on string value create, in add-on string features described in chapter. can utilize string value api requires nsstring instance.

xcode 6.1 / swift 1.1

as @newacct pointed out, in xcode 6.1 / swift 1.1, uppercasestring , lowercasestring are in swift's string class don't need utilize ones defined in nsstring. however, it's implemented extension string class in foundation framework solution still same: import foundation

in playground:

import foundation var sillystring = "this string!" // --> string! allow yellystring = sillystring.uppercasestring // --> string! allow silentstring = sillystring.lowercasestring // --> string!

swift

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -