- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
// NextViewController.swift
override func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) {
NSUserDefaults.standardUserDefaults().setInteger(indexPath.row, forKey: "Selected offense")
let offense: NSDictionary = self.offenses.objectAtIndex(indexPath.row) as NSDictionary
let id: Int = offense.objectForKey("id") as Int
let title: String = offense.objectForKey("title") as String
NSUserDefaults.standardUserDefaults().setInteger(id, forKey: "Selected offense id")
NSUserDefaults.standardUserDefaults().setObject(title, forKey: "Selected offense title")
}
// PreviousViewController.swift
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
hideKeyboard()
tableView.reloadData()
}
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! {
let kCellIndetifier: String = "NewOffenseCell"
var cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier(kCellIndetifier, forIndexPath: indexPath) as UITableViewCell
if cell == nil {
cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: kCellIndetifier)
}
cell.text = NSUserDefaults.standardUserDefaults().stringForKey("Selected offense title")
cell.font = UIFont.systemFontOfSize(20)
return cell
}
Комментарии (1) RSS
Добавить комментарий