Ios Swift空数据集

Ios Swift空数据集,ios,swift,dataset,Ios,Swift,Dataset,我希望创建一个类似于此的空数据集。不是它的外观或任何东西,只是得到一个空数据集的一般概念。我不确定如何做到这一点,我一直想在不使用任何Cocoapod的情况下将其应用到我的应用程序中。这容易吗? 我对斯威夫特还是个新手,所以我还没有弄明白这一点。我尝试了下面的代码,但是有很多错误,我意识到这毫无意义 override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { if

我希望创建一个类似于此的空数据集。不是它的外观或任何东西,只是得到一个空数据集的一般概念。我不确定如何做到这一点,我一直想在不使用任何Cocoapod的情况下将其应用到我的应用程序中。这容易吗? 我对斯威夫特还是个新手,所以我还没有弄明白这一点。我尝试了下面的代码,但是有很多错误,我意识到这毫无意义

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if return == 0 {
        // Create the empty data set
    } else {
        return jsonfile["response"]["data"].count
    }
}

您展示的和其他许多人使用的

在你的例子中也是这样

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    let count = jsonfile["response"]["data"].count
    if count == 0 {
        return 1
    }
    return count
}

然后在
cellForRow:
中返回一个无数据单元格

编辑:

internal func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let count = jsonfile["response"]["data"].count
        if count == 0 {
           return noDataCell
        } else {
           return normalCell
        }
    }

那么,如果cellForRow中的值为0,我将返回什么?我已经有一个返回值,如果大于1,则返回结果。用通常的单元构建或返回单元dequed的方法替换简单单元名称。