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.
- [Instructor] Up to this point in the series,…we've really talked a lot about controllers and views,…but we haven't talked a lot about the model part…of model view controllers.…I want to create a data model…for use with our collection view…that's a little bit more complicated than an array.…We're going to use a type of object called a struct…which allows us to define simple properties…that we can use as data models.…So let's scroll to the top above our class declaration…and we're going to create a struct,…and this will be called ItemInfo.…
You tab into your struct,…create some space,…create two properties in here.…Now what we want to do is have something…that's going to display inside of the collection view cell…and then when you tap on that cell…and head over to the other view controller,…we can send additional data over.…So not only will we have just the selected item,…but maybe some other information, as well.…Maybe a description of that item.…So let's create a variable called name that's a string…and then another variable that's called description,…
- Alert controllers and actions
- Sliders, progress bars, and switches
- Creating UI elements with code
- Displaying web content with Safari view controllers and WKWebView
- Creating collection view controllers
- Creating tabbed apps
- Publishing your app with App Store Connect
Skill Level Beginner
1. Master Views
2. Display Web Content
3. Collection Views
4. Multiview Templates
Customize a table view cell4m 18s
5. Publish an App
Next steps3m 28s
- 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.