Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 3.64 KB | None | 0 0
  1. //
  2. //  RestaurantTableViewController.swift
  3. //  FoodPin
  4. //
  5. //  Created by Lea Abarentos on 19/02/2019.
  6. //  Copyright © 2019 BenildeSwiftCodingClub. All rights reserved.
  7. //
  8.  
  9. import UIKit
  10.  
  11. class RestaurantTableViewController: UITableViewController {
  12.    
  13.     var foodPlaces = ["Bigger Bites", "Yummee", "Foodie", "Deli Zeus", "Food Centro", "Food Char", "Recipes", "Dainty Cuisine", "Food Haven"]
  14.    
  15.     var foodPics = [UIImage(named: "food1"), UIImage(named: "food2"), UIImage(named: "food3"), UIImage(named: "food4"), UIImage(named: "food5"), UIImage(named: "food6"), UIImage(named: "food7"), UIImage(named: "food8"), UIImage(named: "food9"), UIImage(named: "food10")]
  16.  
  17.     override func viewDidLoad() {
  18.         super.viewDidLoad()
  19.  
  20.         // Uncomment the following line to preserve selection between presentations
  21.         // self.clearsSelectionOnViewWillAppear = false
  22.  
  23.         // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
  24.         // self.navigationItem.rightBarButtonItem = self.editButtonItem
  25.     }
  26.  
  27.     // MARK: - Table view data source
  28.  
  29.     override func numberOfSections(in tableView: UITableView) -> Int {
  30.         // #warning Incomplete implementation, return the number of sections
  31.         return 1
  32.     }
  33.  
  34.     override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  35.         // #warning Incomplete implementation, return the number of rows
  36.         return foodPlaces.count
  37.     }
  38.  
  39.    
  40.     override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  41.         let cellIdentifier = "datacell"
  42.         let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as! RestaurantTableViewCell
  43.  
  44.         // Configure the cell...
  45.        
  46.         cell.nameLabel?.text = foodPlaces[indexPath.row]
  47.         cell.thumbnailImageView.image = foodPics[indexPath.row]
  48.        
  49.         return cell
  50.     }
  51.    
  52.  
  53.     /*
  54.     // Override to support conditional editing of the table view.
  55.     override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
  56.         // Return false if you do not want the specified item to be editable.
  57.         return true
  58.     }
  59.     */
  60.  
  61.     /*
  62.     // Override to support editing the table view.
  63.     override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
  64.         if editingStyle == .delete {
  65.             // Delete the row from the data source
  66.             tableView.deleteRows(at: [indexPath], with: .fade)
  67.         } else if editingStyle == .insert {
  68.             // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
  69.         }    
  70.     }
  71.     */
  72.  
  73.     /*
  74.     // Override to support rearranging the table view.
  75.     override func tableView(_ tableView: UITableView, moveRowAt fromIndexPath: IndexPath, to: IndexPath) {
  76.  
  77.     }
  78.     */
  79.  
  80.     /*
  81.     // Override to support conditional rearranging of the table view.
  82.     override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool {
  83.         // Return false if you do not want the item to be re-orderable.
  84.         return true
  85.     }
  86.     */
  87.  
  88.     /*
  89.     // MARK: - Navigation
  90.  
  91.     // In a storyboard-based application, you will often want to do a little preparation before navigation
  92.     override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  93.         // Get the new view controller using segue.destination.
  94.         // Pass the selected object to the new view controller.
  95.     }
  96.     */
  97.  
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement