Handling no data

It is common to want to create a custom view that you can reuse, but also have a visual representation of it as well. There are two common ways to do this: the first way we will demonstrate now, and the other we will do later in this book. You can create a UIView that comes with a XIB (pronounced zib or nib). XIBs were the common way to create elements before storyboards, and are still effective today. Let's create one now:

  1. Right-click on the Misc folder and select New Group and call it No Data.
  2. Then, right-click on the No Data folder and create a new file.
  3. On the Choose a template for your new file screen, select iOS at the top. Then, select Cocoa Touch Class. Then, hit Next.
  1. In the options screen that appears, add the ...

Get iOS 12 Programming for Beginners - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.