Swift学习

从今天开始系统学习Swift,并且把学习的源代码放在Github上面,大家觉得好的话可以加颗星,多谢。

https://github.com/JohnnySheng/MySwiftSamples

第一部分,基础知识

1.1String的日常使用

 //1. 可以使用特殊字符
        let str = "Hello"
        let smile = "这里可以放笑脸"
        let combined = str + " " + smile
        print(combined)
        
        //2. NSInteger转变成String
        var coinCount:NSInteger = 5
        coinCount = coinCount + 1
        print("你的币值是:" + String(coinCount))
        
        //3. 解析一个String, 通过空格分解句子
        
        let longSting = "With this book we try to shine a new light on a framework that has been around for a while"
        let components:[String] = longSting.componentsSeparatedByString(" ")
        for aString in components{
            print(aString)
        }

猜你喜欢

转载自johnie-sheng.iteye.com/blog/2273564