如何使用Core Data将A-Z添加为节标题标题-Swift

时间:2019-06-30 06:36:41

标签: uitableview core-data swift4 sectionheader

如何使用Core Data将A-Z添加为节标题标题-Swift 我是新手。

我有coredata:

CoreData Image

和我的代码:

     var arrContacts = [NSManagedObject]()


    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        if search{
            return arrSearched.count
        }
        else {
            return arrContacts.count
        }
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "Cell") as! ContactViewCell
        if search {
            cell.lbContactName.text = arrSearched[indexPath.row].value(forKey: "name") as! String
        }
        else {
            cell.lbContactName.text = arrContacts[indexPath.row].value(forKey: "name") as! String
        }
        return cell
    }
}

如何使我的应用程序如此?

Contacts sort by A-Z

对不起,我的英语太差了!

0 个答案:

没有答案
相关问题