Skip to content

Instantly share code, notes, and snippets.

@jazzbpn
Last active July 4, 2018 07:40
Show Gist options
  • Save jazzbpn/7a26056573d8013f3d388a23bd546e86 to your computer and use it in GitHub Desktop.
Save jazzbpn/7a26056573d8013f3d388a23bd546e86 to your computer and use it in GitHub Desktop.
import UIKit
class NoticeViewController: UIViewController {
var presentor:ViewToPresenterProtocol?
@IBOutlet weak var uiTableView: UITableView!
var noticeArrayList:Array<NoticeModel> = Array()
override func viewDidLoad() {
super.viewDidLoad()
self.title = "Notice-Module"
presentor?.startFetchingNotice()
showProgressIndicator(view: self.view)
uiTableView.delegate = self
uiTableView.dataSource = self
}
}
extension NoticeViewController:PresenterToViewProtocol{
func showNotice(noticeArray: Array<NoticeModel>) {
self.noticeArrayList = noticeArray
self.uiTableView.reloadData()
hideProgressIndicator(view: self.view)
}
func showError() {
hideProgressIndicator(view: self.view)
let alert = UIAlertController(title: "Alert", message: "Problem Fetching Notice", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "Okay", style: UIAlertActionStyle.default, handler: nil))
self.present(alert, animated: true, completion: nil)
}
}
extension NoticeViewController:UITableViewDelegate, UITableViewDataSource{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return noticeArrayList.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! NoticeCell
cell.id.text = noticeArrayList[indexPath.row].id
cell.title.text = noticeArrayList[indexPath.row].title
cell.brief.text = noticeArrayList[indexPath.row].brief
cell.file_source.text = noticeArrayList[indexPath.row].filesource
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
presentor?.showMovieController(navigationController: navigationController!)
}
}
class NoticeCell:UITableViewCell{
@IBOutlet weak var id: UILabel!
@IBOutlet weak var title: UILabel!
@IBOutlet weak var brief: UILabel!
@IBOutlet weak var file_source: UILabel!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment