我是使用Swift语言进行iOS开发的新手.
我在我的应用程序中使用CoreData作为数据库选项.
我正在使用NSFetchRequest从表中获取记录.我可以从表中检索所有记录,但我无法从同一个表中检索特定的行.我已经在线和其他论坛检查了解决方案,但我无法为此获得适当的解决方案.
我想只在Swift中实现它.我不想添加sqlite库或Bridging-wrapper(Objective-C),这将是我实现此目的的最后一个选项.
任何链接或教程或建议都会有所帮助.
我的tableview应用看起来像这样:
我不知道为什么这label1
不起作用。
这是我的操作方法:
我拖动了一个UITableViewController
并将其设置为initialViewController。
我将UITableViewCell样式设置为 Custom
然后我设置UITableViewController的 Custom Class
和UITableViewCell的
然后,我添加了一些约束:
这里是TableViewController.swift
:
import UIKit
class TableViewController: UITableViewController {
let arr = ["abc", "def", "ghi", "jkl", "mno"]
override func viewDidLoad() {
super.viewDidLoad()
}
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1 // This should more than one if you want to see the sections and rows in your tableview
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return arr.count
}
override …
Run Code Online (Sandbox Code Playgroud)