Skip to content

Instantly share code, notes, and snippets.

@hayate1996
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hayate1996/123ea860a5f58ee3b605 to your computer and use it in GitHub Desktop.
Save hayate1996/123ea860a5f58ee3b605 to your computer and use it in GitHub Desktop.
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