New to Swift - Value of Type 'String' has no member 'emoji' error

Hello I have been studying Swift about 6 months and going through Apple Books tutorials for Swift. I have ran into a error I cannot figure out, I need help in getting pointed in the right direction to figure this one out, code is below.

class ViewController: UIViewController {

var topChoices = ["😡", "🐶","🐳"]
var bottomChoices = ["You know what I don't like", "Dogs with cigars", "Fish Out Of Water"]


override func viewDidLoad() {

    super.viewDidLoad()

    topCaptionSegmentControl.removeAllSegments()

    for choice in topChoices {

       topCaptionSegmentControl.insertSegment (withTitle: choice.emoji, at: topChoices.count, animated: false)

    }

    

    topCaptionSegmentControl.selectedSegmentIndex = 0

    

}

    // Do any additional setup after loading the view, typically from a nib.

}

/*

override func didReceiveMemoryWarning() {

    super.didReceiveMemoryWarning()

    // Dispose of any resources that can be recreated.

}

*/

What line has the error? Paste the error message into your post.

Sorry about that,

The error is at the line below, at least that is where Swift displays the error:

for choice in topChoices {
topCaptionSegmentControl.insertSegment (withTitle: choice.emoji, at: topChoices.count, animated: false)

    }

Error received is: Value of type ‘String’ has no member ‘emoji’

topCaptionSegmentControl.insertSegment (withTitle: choice.emoji, at: topChoices.count, animated: false)

You know topChoices is an array of strings, right?

And, you know for choice in topChoices is iterating over an array of strings, right?

So what type is choice?

The error is "‘String’ has no member ‘emoji’. Did you define ‘emoji’ anywhere?

I don’t think Swift defined ‘emoji’ anywhere.

What happens if you remove that word from your code?

If I understand your intent correctly, you want to call insertSegment() with a UIImage that represents the corresponding emoji.

But emoji such as 🐳 are not images; they are text. You need to explicitly render the text to some kind of canvas to produce an image. (There’s probably a quick and easy way to do this, maybe with an add-on library, but not having had to do this myself, I can’t cite it off the top of my head…)