The concept of `var status = (string: statusVal as NSString)` variable declaration in Swift

I found the following code in a project that compiles and runs successfully. But I can’t understand how this works. I tried using it on Google using various search phrases, but could not find an explanation.

let statusVal = "Somestring"
var status = (string: statusVal as NSString)

Can someone clarify what happens on the second line? According to the little knowledge I have in Swift, the second line should be something like

var status = NSString(string: statusVal as NSString)

which of course compiles.

+4
source share
2 answers

So far this is just a tuple with one element

var status = (abcdefg:"abc")

abcdefg - , "abc" - .

, . , String

https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html

+4

, var status = statusVal as NSString, string: , . string:, .

+2

Source: https://habr.com/ru/post/1616384/


All Articles