Monday, April 17, 2017

Hello World App Explanation (Xcode 8.2.1 Swift 3.1)




showMessage method

  @IBAction func showMessage() {
        let alertController = UIAlertController(title: "Welcome to My First App",
                                                message: "Hello World", preferredStyle: UIAlertControllerStyle.alert)
        alertController.addAction(UIAlertAction(title: "OK", style:
            UIAlertActionStyle.default, handler: nil))
        present(alertController, animated: true, completion: nil)
    }



1. Func – keyword to declare a method
2. showMessage()method name and parameters
3. @IBAction – keyword to expose the method to interface builder
4. import – keyword to access external frameworks ( ex. UIkit)
5. let – to define a constant
6. alertController – constant name

7. UIAlertController(title: "Welcome to My First App", message: "Hello World", preferredStyle: UIAlertControllerStyle.alert) – an object in which we specify the title, message and the style of the alert

8. alertController.addAction – it is a method to add action to the alert so that is displays “OK” button


9. present – present alertController object with animation

Friday, April 14, 2017

How to Make Hello World App Xcode (8 Swift 3.0)



function for Hello World Button

@IBAction func showMessage() {
        let alertController = UIAlertController(title: "Welcome to My First App",
                                                message: "Hello World", preferredStyle: UIAlertControllerStyle.alert)
        alertController.addAction(UIAlertAction(title: "OK", style:
            UIAlertActionStyle.default, handler: nil))
        present(alertController, animated: true, completion: nil)
    }