Home>

There are parts of the following sources that are not understood. I would appreciate any advice.

import UIKit
class OmikuziViewController: UIViewController {
    // Variable to receive the name from the previous page
    var name: String? = ""
    // Store fortune results in an array
    var result: [String] = ["Daiyoshi", "Nakayoshi", "Koyoshi", "Bad"]
    // Link the label to display the name and fortune results to the Controller
    @IBOutlet weak var nameLabel: UILabel!
    @IBOutlet weak var resultLabel: UILabel!
    // viewDidLoad is executed when the page is displayed
    override func viewDidLoad () {
        super.viewDidLoad ()
        // Check if the received name contains nil
        if let name = name {
            // If nil is not included, display the name in Label
            nameLabel.text = name + "san"
        }
        // get a random number 0 ~ 3 and display the fortune value from the array according to the result
        let num = Int (arc4random_uniform (4))
        resultLabel.text = "\ (result [num])!"
    }
    override func didReceiveMemoryWarning () {
        super.didReceiveMemoryWarning ()
    }

}
var name: String? = ""

It's a variable in this string, but you can see that name is a variable, but then

: String? = ""


What does this: String?mean?
The surprise mark is sometimes used in a negative sense, but is it related?
And what does it mean to addString?after the name variable?