This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Given the string, check if it is a palindrome. | |
//Example | |
// For inputString = "aabaa", the output should be | |
// solution(inputString) = true; | |
// For inputString = "abac", the output should be | |
// solution(inputString) = false; | |
// For inputString = "a", the output should be | |
// solution(inputString) = true. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Given a year, return the century it is in. The first century spans from the year 1 up to and including the year 100, the second - from the year 101 up to and including the year 200, etc. | |
//Example | |
// For year = 1905, the output should be | |
// solution(year) = 20; | |
// For year = 1700, the output should be | |
// solution(year) = 17. | |
func solution(year: Int) -> Int { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Simple Alert with Text input | |
*/ | |
func showAlertWithTextField() { | |
let alertController = UIAlertController(title: "Add new tag", message: nil, preferredStyle: .alert) | |
let confirmAction = UIAlertAction(title: "Add", style: .default) { (_) in | |
if let txtField = alertController.textFields?.first, let text = txtField.text { | |
// operations | |
print("Text==>" + text) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Simple Alert with Distructive button | |
*/ | |
func showAlertWithDistructiveButton() { | |
let alert = UIAlertController(title: "Sign out?", message: "You can always access your content by signing back in", preferredStyle: UIAlertControllerStyle.alert) | |
alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.default, handler: { _ in | |
//Cancel Action | |
})) | |
alert.addAction(UIAlertAction(title: "Sign out", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Simple Action Sheet | |
- Show action sheet with title and alert message and actions | |
*/ | |
func showSimpleActionSheet(controller: UIViewController) { | |
let alert = UIAlertController(title: "Title", message: "Please Select an Option", preferredStyle: .actionSheet) | |
alert.addAction(UIAlertAction(title: "Approve", style: .default, handler: { (_) in | |
print("User click Approve button") | |
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Simple Alert | |
- Show alert with title and alert message and basic two actions | |
*/ | |
func showSimpleAlert() { | |
let alert = UIAlertController(title: "Sign out?", message: "You can always access your content by signing back in", preferredStyle: UIAlertControllerStyle.alert) | |
alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.default, handler: { _ in | |
//Cancel Action | |
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Alerts.swift | |
// ExploringUIAlertView | |
// | |
// Created by Balaji Malliswamy on 30/05/18. | |
// Copyright © 2018 NFNLabs. All rights reserved. | |
// | |
import UIKit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.swift | |
// StackoverflowWorks | |
// | |
// Created by Balaji Malliswamy on 03/03/17. | |
// Copyright © 2017 NFNLabs. All rights reserved. | |
// | |
import UIKit |