cuốn sách gpt4 ai đã làm

ios - 从从 Parse.com 中提取的数组中获取索引 - fatal error : Cannot index empty buffer

In lại Tác giả: Hồ Xil 更新时间:2023-11-01 02:21:05 26 4
mua khóa gpt4 Nike

我是 Swift 的新手,我一直在尝试从存储在 Parse.com 中的数组中提取单个项目

当打印数组本身时,我得到了所有用户,但是,当试图获取数组的第一个索引时,我得到以下错误

"fatal error: Cannot index empty buffer"

这是我目前正在使用的代码 -

nhậpUIKit
import Parse
class feedTableViewController: UITableViewController {
var titles = [String]()
var usernames = [String]()
var images = [UIImage]()
var imageFiles = [PFFile]()

ghi đè 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
}
}

Cảm ơn!

câu trả lời hay nhất

确保 titles 中的元素数量与您在 numberOfRowsInSection 中返回的数量相匹配。

关于ios - 从从 Parse.com 中提取的数组中获取索引 - fatal error : Cannot index empty buffer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31007449/

26 4 0
Hồ Xil
Hồ sơ

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá taxi Didi miễn phí
Phiếu giảm giá taxi Didi
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress