I'm fairly new to Swift
and I've been trying to pull individual items from an array stored in Parse.com
When printing the array itself, I get all the users, however, when attempting to get the first index of an array I get the following error
"fatal error: Cannot index empty buffer"
This is code I'm currently using -
import UIKit
import Parse
class feedTableViewController: UITableViewController {
var titles = [String]()
var usernames = [String]()
var images = [UIImage]()
var imageFiles = [PFFile]()
override func viewDidLoad() {
super.viewDidLoad()
//....
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var myCell:cell = self.tableView.dequeueReusableCellWithIdentifier("myCell") as cell
//Error occurs here - does not work due to empty buffer
myCell.title.text = titles[indexPath.row]
myCell.username.text = usernames[indexPath.row]
//If the previous two lines are commented out, I can print out both the arrays
println(titles)
println(usernames)
return myCell
}
}
Thanks!
Make sure the number of elements in
titles
matches the number you return innumberOfRowsInSection
.