Learn Courses My Dashboard

Xcode doesn't like code, but won't say why

Xcode gives me:
“Failed to produce diagnostic for expression…” when I include the code between /* and */ .
I thought I had faithfully followed the video for M2L14.

The code below the dotted line is a modification of business.swift of M6L12

var body: some View {
    VStack (alignment: .leading) {
        HStack {
            // Office and picture
            VStack (alignment: .leading) {
                Image(String(business.name ?? ""))
                    .frame(width:58, height:58)
                Text(business.name ?? "")
            HStack {
           { ForEach (business.AWTStaff,id:/.self) { r in Text(r) }




import Foundation

class Business: Decodable, Identifiable, ObservableObject {

@Published var imageData: Data?

var id: String?
var alias: String?
var name: String?
var imageUrl: String?
var isClosed: Bool?
var url: String?
var reviewCount: Int?
var categories: [Category]?
var rating: Double?
var coordinates: Coordinate?
var transactions: [String]?
var price: String?
var location: Location?
var phone: String?
var displayPhone: String?
var distance: Double?

var Address: String?
var AWTStaff: [String]?

enum CodingKeys: String, CodingKey {
    case imageUrl = "image_url"
    case isClosed = "is_closed"
    case reviewCount = "review_count"
    case displayPhone = "display_phone"
    case id
    case alias
    case name
    case url
    case categories
    case rating
    case coordinates
    case transactions
    case price
    case location
    case phone
    case distance
    case Address
    case AWTStaff

Several issues here:

  1. You have too many brackets.
 HStack {
 { ForEach (business.AWTStaff,id:/.self) { r in Text(r) }

should be:

HStack {
    ForEach (business.AWTStaff, id:/.self) { r in 
  1. business.AWTStaff is an Optional array [String]? so you need to unwrap it before you can use it. One way you can do it is like this:
HStack {
    ForEach (business.AWTStaff ?? [], id:/.self) { r in 
  1. The slash on the id parameter to ForEach is backwards.

should be:


Thank you for the suggestions, they worked. I had thought about AWTStaff being an optional, but never implemented it. I provided screenshots to my coworkers, they were enthusiastic, and we plan to discuss next Friday at our weekly meeting.
Thanks again.