Reputation: 2094
I am trying to populate a UITableView with some data that I have stored in an NSMutableArray (not sure if it should just be an Array?).
The table consists of a custom cell which I have designed in the Storyboard which I have given the identifier: courseCell
To try and populate the UITableView with my data in my NSMutableArray, I was using this tutorial: http://www.codingexplorer.com/getting-started-uitableview-swift/ however it gets to a point where they are populating the cells using "cellForRowAtIndexPath", but they are just using the default cell style and so do the following:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier(textCellIdentifier, forIndexPath: indexPath) as UITableViewCell
let row = indexPath.row
cell.textLabel?.text = swiftBlogs[row]
return cell
}
But I am using a custom cell which has two labels.
I wasn't sure what to do, so I made an outlet for the labels and also the prototype cell:
@IBOutlet var coursesTableView: UITableView!
@IBOutlet weak var customCell: UITableViewCell!
@IBOutlet weak var courseNameLabel: UILabel!
@IBOutlet weak var courseCodeLabel: UILabel!
I am a little lost and not sure how I can go through the cellForRowAtIndexPath function, loading in my NSMutableArray data into the two labels. Any help would be appreciated!
NOTE: I am only new to StackOverflow to please let me know if I have not been clear enough.
Upvotes: 0
Views: 1001
Reputation: 11435
If you are using a custom UITableViewCell
, then you need to create a class for that custom cell (and connect the cell with the class in storyboard).
This tutorial explains very well how custom cells work: LINK
Note: Your problem is not with NSMutableArray
, it's populating the custom cell.
Upvotes: 1