---
title: "#14: DZNEmptyDataSet 🐚"
url: https://littlebitesofcocoa.com/14-dznemptydataset
author: Jake Marsh
published: 2015-06-04
topics: ["Libraries"]
description: "DZNEmptyDataSet is a library that makes it extremely easy to add custom \"empty\" data sets, for when a screen in your app either currently has no data, or..."
---

# #14: DZNEmptyDataSet 🐚

By Jake Marsh, June 4, 2015. HTML: https://littlebitesofcocoa.com/14-dznemptydataset

**DZNEmptyDataSet** is a library that makes it extremely easy to add custom "empty" data sets, for when a screen in your app either currently has no data, or the user hasn’t created any data yet.

You can configure it by implementing a bunch of different optional methods in the `DZNEmptyDataSet` protocol. A pretty simple setup is shown here, but the there are lots of more advanced options including custom views and even easily adding a button below the text.

``` swift
extension PhotosViewController : DZNEmptyDataSetSource {
  func titleForEmptyDataSet(scrollView: UIScrollView!) -> NSAttributedString! {
    return NSAttributedString(string: "No Photos")
  }

  func descriptionForEmptyDataSet(scrollView: UIScrollView!) -> NSAttributedString! {
    let text = "Photos you take will appear here"

    return NSAttributedString(string: text, attributes: [
      NSForegroundColorAttributeName: UIColor.grayColor()
    ])
  }
  
  func imageForEmptyDataSet(scrollView: UIScrollView!) -> UIImage! {
    return UIImage(named: "cracked-egg")
  }
}
```

Detect interaction by implementing one of the methods in the `DZNEmptyDataSetDelegate` protocol.

``` swift
extension PhotosViewController : DZNEmptyDataSetDelegate {
  func emptyDataSetDidTapButton(scrollView: UIScrollView!) {
    println("tapped button on the empty view!")
  }
}
```

Here's some example empty screens **DZNEmptyDataSet** can help you create:

<img src="https://media.littlebitesofcocoa.com/bite-assets/014-dznemptyset-examples.png" style="max-width: 411px;" />

## Example Project

[You can download a complete working project here](http://j.mp/bite014)

## More Info

More info about **DZNEmptyDataSet** can be found at [git.io/empty](http://git.io/empty)
