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
No comments:
Post a Comment