Post

Replies

Boosts

Views

Activity

Reply to Tuple Comparision
true and false are not 1 and 0 as in other languages. But of course, this works let myTuple = ("blue", 0) let otherTuple = ("blue", 1) if myTuple < otherTuple { print("yes it evaluates") } and this as well: let myTuple2 = ("blue", false) let otherTuple2 = ("blue", true) if myTuple2 == otherTuple2 { print("yes it evaluates") } else { print("Not equal") } You may be interested in reading this discussion in Swift forum: https://forums.swift.org/t/why-bool-doesnt-conform-to-comparable/10698/6
Topic: Programming Languages SubTopic: Swift Tags:
Jul ’25
Reply to Trying to Connect an Outlet to a Gesture Recogniser in Storyboard
I have created the tap gesture in storyboard and added it to the view controller hierarchy by dragging the tap gesture onto the view controller. You drag in the viewController, and try to apply to multiple objects (each cell's label: that's what "repeating content" means here). That cannot work as a gesture is attached to a unique object. So you need as many tapGestures as there are cells. The simplest in your case would be to create the tap gesture in code, in the init of collectionCell. Or try to declare the tapGesture in storyboard in the cell.
Topic: UI Frameworks SubTopic: UIKit Tags:
Jul ’25
Reply to Trying to Connect an Outlet to a Gesture Recogniser in Storyboard
You do not provide enough information about you proceeded. Did you do those steps ? create a tapGesture in storyboard by dragging the object in the viewController structure ? -> Could you show the attributes inspector of the tapGesture ? you control dragged in storyboard from the tapGesture to the label object in the viewController structure (in storyboard)? -> Do you see the tapGesture listed Connections inspector of the label? You say: When I connect the outlet to the gesture recogniser I get this error: How exactly do you try to connect ? Is it the label in storyboard or IBOutlet in code (you should not do it) ? Please clarify   How can I connect the tap gesture recogniser in storyboard to my code? What do you want to connect exactly in code ? You don't have to connect the tapGesture to the label IBOutlet in code. The connection is made in storybaord as explained before. If you want to declare an action for the tapGesture, then create the IBAction @IBAction func tapped(_ sender: UITapGestureRecognizer) { } select the tapGesture in stroryboard corntrol-drag from the tapgesture to the IBAction -> You should now see "tapped" in the connections inspector of the tapGesture in the sent actions section. It seems you have tried to connect the incrementNumberOfTaps action to the cell and not to the tapGesture.
Topic: UI Frameworks SubTopic: UIKit Tags:
Jul ’25
Reply to Cell Delegate Method Not Being Called
When looking at code in documentation, registration is done differently, by creating a default content configuration and then adjusting: let cellRegistration = UICollectionView.CellRegistration<UICollectionViewListCell, Int> { cell, indexPath, item in var contentConfiguration = cell.defaultContentConfiguration() contentConfiguration.text = "\(item)" contentConfiguration.textProperties.color = .lightGray cell.contentConfiguration = contentConfiguration } Could you also test with a log: let mainCellRegistration = UICollectionView.CellRegistration<EmotionExplorerCell, Item> { cell, indexPath, item in print("cell", cell, indexPath, item) // <<-- ADD THIS switch item { case .main(emotion: let emotion, icon: let iconName, red: let red, green: let green, blue: let blue) : cell.configure(iconName: iconName, title: emotion, red: red, green: green, blue: blue) cell.index = indexPath.row cell.delegate = self case .title(title: -, buttonTitle:
Topic: UI Frameworks SubTopic: UIKit
Jul ’25
Reply to Cell Delegate Method Not Being Called
However, calling the cell delegate method from the cell is not calling the method in the view controller. It's not very clear.   calling the cell delegate method from the cell Which method is it ? repromptLLMForIconName ?   is not calling the method in the view controller. Which method is it ? Have you checked that delegate is not nil ? print("delegate", delegate) delegate?.repromptLLMForIconName(iconName, index: index, emotion: emotion, red: red, green: green, blue: blue)
Topic: UI Frameworks SubTopic: UIKit
Jul ’25