I would like to populate so many rows in a tableview as I have entries defined. At my actual code I receive only the first item.
What I expect is to have all 3 countries populated.
my code looks like this:
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// How many sections. Means numberOfSections * rows = view
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
// Defines the number of rows in a section table
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
return 1
}
// Defines contet of each cell
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
//let cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "Cell")
let cell = tableView.dequeueReusableCellWithIdentifier("myCell", forIndexPath: indexPath) as! myCell
var countries = ["Turkey","Croatia","USA"]
var logoImageTUR = UIImage(named: "turkey.png")
var logoimageCRO = UIImage(named: "croatia.png")
var logoimageUSA = UIImage(named: "USA.png")
var countryLogos = [logoImageTUR, logoimageCRO, logoimageUSA]
for var i = 0; i < 2; i++
{
cell.lbl_countryName.text = countries[i]
cell.img_countryFlag.image = countryLogos[i]
return cell
}
}
}
Thank you