Skip to content

Instantly share code, notes, and snippets.

@aritaku
Created August 31, 2016 02:47
Show Gist options
  • Save aritaku/c0e5a2a0e0574d07f24d0937f1d53f78 to your computer and use it in GitHub Desktop.
Save aritaku/c0e5a2a0e0574d07f24d0937f1d53f78 to your computer and use it in GitHub Desktop.
import UIKit
class ScoreController: UITableViewController {
var userData = NSUserDefaults.standardUserDefaults()
var dataArray = [AnyObject]()
override func viewDidLoad() {
super.viewDidLoad()
self.title = "スコアリスト"
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(true)
if let data = userData.arrayForKey("score") {
dataArray = data
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return dataArray.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)
cell.textLabel!.text = dataArray[indexPath.row] as? String
return cell
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
_ = segue.destinationViewController as! ScoreSecondController
}
func showAlart2() {
let alertController = UIAlertController(title: "タイトル", message: "ここに入力", preferredStyle: .Alert)
let defaultAction = UIAlertAction(title: "OK", style: .Default, handler: {
(action:UIAlertAction!) -> Void in
})
let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: {
(action) -> Void in
})
alertController.addAction(defaultAction)
alertController.addAction(cancelAction)
alertController.addTextFieldWithConfigurationHandler({(text:UITextField) -> Void in
text.placeholder = "vs ◯◯校"
})
self.presentViewController(alertController, animated: true, completion: nil)
}
@IBAction func newCreate() {
showAlart2()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment