Swift - which types to use? NSString or String

后端 未结 9 1041
死守一世寂寞
死守一世寂寞 2020-12-23 00:06

With the introduction of Swift I\'ve been trying to get my head round the new language

I\'m an iOS developer and would use types such as NSString, NSInteger, N

9条回答
  •  渐次进展
    2020-12-23 00:46

    Use the Swift native types whenever you can. In the case of String, however, you have "seamless" access to all the NSString methods like this:

    var greeting = "Hello!"
    var len = (greeting as NSString).length
    

提交回复
热议问题