Core Data: Beyond the Basics

Jul 26 2022 · Swift 5.5, iOS 15, Xcode 13.3.1

Part 1: Fetching & Displaying Launches

10. Challenge - Displaying Tags

Episode complete

Play next episode

About this episode

Leave a rating/review

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 09. Challenge - Adding Tags Next episode: 11. Transient Properties

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

Now that your object graph can store tags you need a way to display them. This is part two of your challenge - to display all the tags that have been added to launches so far.

@State var isShowingTagsModal: Bool = false
  Button(action: { self.isShowingTagsModal.toggle() }) {
  }.sheet(isPresented: self.$isShowingTagsModal, content: {
@Environment(\.managedObjectContext) var viewContext
let tags: [Tag]
NavigationView {
  VStack {
    List {
      Section {
        ForEach(tags, id: \.self) {tag in 
struct TagsView_Previews: PreviewProvider {
    static var previews: some View {
      let context = PersistenceController.preview.container.viewContext
      let tag = Tag(context: context)
      tag.title = "Test"
      return TagsView(tags: [tag])
var tags: Array<Tag> {}
let tagsSet = launchList.launches
let tagsSet = launchList.launches.compactMap({$0.tags})
let tagsSet = launchList.launches.compactMap({$0.tags}).reduce(Set<Tag>(), {(result, tags) in
  var result = result
  return result
return Array(tagsSet)
TagsView(tags: self.tags)