Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- class StoreListMainViewController: UIViewController,UITableViewDelegate, UITableViewDataSource{
- // TableView
- @IBOutlet weak var tableView: UITableView!
- var StoreLocation: [String] = []
- //Loop for data from database
- var pStoreName = [String]()
- if let jsonResponsePlanDetail = jsonResponsePlanDetail{
- for dictionary in jsonResponsePlanDetail{
- pStoreName.append(dictionary["StoreShortName"]! as! String)
- print("pStoreName ==> (pStoreName)")
- self.StoreLocation = pStoreName
- print("StoreLocation ==> (self.StoreLocation)")
- }//for
- }//if
- // TableView
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return StoreLocation.count
- }
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as? cellTableViewCell
- cell!.Location.text = StoreLocation[indexPath.row]
- cell!.DepartureTime.text = StoreLocation[indexPath.row]
- return cell!
- }
- //go to detail viewController
- }
- //Cell
- import UIKit
- class cellTableViewCell: UITableViewCell {
- @IBOutlet weak var Location: UILabel!
- @IBOutlet weak var DepartureTime: UILabel!
- override func awakeFromNib() {
- super.awakeFromNib()
- }
- override func setSelected(_ selected: Bool, animated: Bool) {
- super.setSelected(selected, animated: animated)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement