Last active
August 29, 2015 14:27
-
-
Save hayate1996/123ea860a5f58ee3b605 to your computer and use it in GitHub Desktop.
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
import UIKit | |
class ViewController: UIViewController { | |
@IBOutlet var loginButton: UIButton! | |
var accountsList:[Dictionary<String,String>]? | |
var tweets:[Dictionary<String, AnyObject>]? | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
self.navigationItem.title = "Login" | |
accountsList = [["name":"Hiro"], ["name":"Jeff"], ["name":"Chris"]] | |
} | |
override func didReceiveMemoryWarning() { | |
super.didReceiveMemoryWarning() | |
// Dispose of any resources that can be recreated. | |
} | |
@IBAction func tappedLoginButton(sender: AnyObject) { | |
var accountSelectionSheet = UIAlertController() | |
accountSelectionSheet.title = "Select Account" | |
let selectAction = { (var action: UIAlertAction!) -> Void in | |
self.performSegueWithIdentifier("showTimelineViewController", sender: nil) | |
} | |
if let accounts:[Dictionary<String, String>] = accountsList{ | |
for account in accounts { | |
let action = UIAlertAction(title: account["name"]!, style: .Default, handler: selectAction) | |
accountSelectionSheet.addAction(action) | |
} | |
} | |
let CanceledAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: nil) | |
accountSelectionSheet.addAction(CanceledAction) | |
self.presentViewController(accountSelectionSheet, animated: true, completion: nil) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment