Most of the time when you create a table view or a collection view, you'll want to have a custom data structure (usually referred to as a model) to store the data. This video shows how to create a custom data type.
- [Narrator] Often when you create an app like this…you want to have some kind of custom data type…to send to the second view that you show when you select one…of the items.…Or maybe you want to display multiple pieces…of data within a cell and you need some kind…of data model for that.…Let's take a look at how that could work.…Underneath my private let statement here…I'm going to create a struct,…and we're going to call this Item.…And then for fields, we'll just have a title field…that'll be a string and then a description.…
So each cell is going to have both a title…and a description.…Let's scroll down a little bit…and we're going to make an array of these item objects…and use the data from those to populate our cells.…So underneath our itemSize declaration I'm going…to create a variable called items…and that's going to be an array of item objects…which will initialize to an empty array.…
At the bottom of viewDidLoad I'm going…to append to the array.…So items.append…and then it asks for a new element.…So I'm going to create an item…
- Advanced UI controls
- Creating alert controllers
- Displaying web content
- Creating a collection view controller
- Creating a custom data type
- Creating tabbed apps
- Importing and setting icons for your apps
- Publishing your app to the App Store
Skill Level Beginner
iOS and watchOS App Development: Notificationswith Steven Lipton3h 45m Intermediate
1. Mastering Views
2. Display Web Content
3. Collection Views
4. Multi-View Templates
5. Publish an App
Next steps1m 21s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.