Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // BairrosTableViewController.swift
- // TuristandoRio
- //
- // Created by abiliojr on 9/27/16.
- // Copyright © 2016 abittencourt. All rights reserved.
- //
- import UIKit
- class BairrosTableViewController: UITableViewController {
- var pontosT:NSArray?
- var bairros:Array<String>!
- let showListLocaisIdentifier = "showListLocais"
- let identifier = "bairroCell"
- override func viewDidLoad() {
- super.viewDidLoad()
- if let bundlePath = NSBundle.mainBundle().pathForResource("Places", ofType: "plist"){
- if let dicionario = NSDictionary(contentsOfFile: bundlePath){
- pontosT = dicionario["places"]! as? NSArray
- bairros = []
- for a in pontosT! {
- if(!bairros.contains(a.valueForKey("Bairro") as! String)){
- bairros.append(a.valueForKey("Bairro") as! String)
- }
- }
- tableView.reloadData()
- }
- }
- }
- override func tableView(tableView: UITableView, numberOfRowsInSection section: Int)-> Int{
- return (bairros.count)
- }
- override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath:NSIndexPath) -> UITableViewCell{
- var cell:UITableViewCell? = tableView.dequeueReusableCellWithIdentifier(identifier)
- if cell == nil{
- cell = UITableViewCell(style: .Default, reuseIdentifier: identifier)
- }
- cell?.textLabel?.text = bairros?[indexPath.row]
- cell?.textLabel?.textColor = UIColor.whiteColor()
- return cell!
- }
- override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
- if let index = tableView.indexPathForSelectedRow{
- if segue.identifier == showListLocaisIdentifier{
- if let destination = segue.destinationViewController as? ListLocaisTableViewController{
- destination.bairroSelecionado = bairros![index.row]
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement