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.
}
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...)