I am new to this and need your help. Can anybody tell me how I can change this code so it produces an Array of Strings rather than an Array of Integers. Thank you for your time and any help you may have to offer.
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var objTable: UITableView!
var numberArray = NSMutableArray()
var selectedArray=NSMutableArray()
override func viewDidLoad() {
super.viewDidLoad()
for index in 1...200 {
numberArray.add(index)
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
return numberArray.count;
}
func tableView(_ tableView: UITableView, cellForRowAtIndexPath indexPath: IndexPath) -> UITableViewCell
{
let contact = numberArray.object(at: indexPath.row)
let cell:MyCustomClass = objTable.dequeueReusableCell(withIdentifier: "reuseCell") as! MyCustomClass
cell.textLabel?.text = String("Number \(contact)")
cell.tickButton.addTarget(self, action:#selector(ViewController.tickClicked(_:)), for: .touchUpInside)
cell.tickButton.tag=indexPath.row
if selectedArray .contains(numberArray.object(at: indexPath.row)) {
cell.tickButton.setBackgroundImage(UIImage(named:"Select.png"), for: UIControlState())
}
else
{
cell.tickButton.setBackgroundImage(UIImage(named:"Diselect.png"), for: UIControlState())
}
return cell
}
func tickClicked(_ sender: UIButton!)
{
let value = sender.tag;
if selectedArray.contains(numberArray.object(at: value))
{
selectedArray.remove(numberArray.object(at: value))
}
else
{
selectedArray.add(numberArray.object(at: value))
}
print("Selected Array \(selectedArray)")
objTable.reloadData()
}
func tableView(_ tableView: UITableView, heightForRowAtIndexPath indexPath: IndexPath) ->CGFloat
{
return 80.0
}
}