Swift learning

Start systematically learning Swift today, and put the source code of learning on Github. If you think it is good, you can add a star, thank you.

https://github.com/JohnnySheng/MySwiftSamples

 

Part 1, Basics

1.1 Daily use of String

//1. Special characters can be used
        let str = "Hello"
        let smile = "You can put a smiley face here"
        let combined = str + " " + smile
        print(combined)
        
        //2. NSInteger is converted to String
        var coinCount: NSInteger = 5
        coinCount = coinCount + 1
        print("Your currency value is: " + String(coinCount))
        
        //3. Parse a String, decompose sentences by spaces
        
        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)
        }

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327061467&siteId=291194637