Minor Bugs, Major Improvements: What We’re Fixing”

Jerry PM
4 min readOct 1, 2024

The bug or issue that occurred in my work this month

Issue 1: Default in variable model swift

While working on a task at my current job, I received a ticket to address a bug related to an API. The API response uses the key default, which conflicts with Swift's reserved keyword default. Using default as a variable name results in an error: "If this name is unavoidable, use backticks to escape it."

To resolve this issue, I found that the best solution is to use backticks to escape the variable name. Therefore, the code should be written as:

var `default`: Bool = false

To make the code more organized, I have modified the variable naming to be more structured as follows:

struct DataModel: HandyJSON {
var `default`: Bool = false

var isDefault: Bool {
self.default
}
}

Issue 3: Fix Auto-Scroll Selection

I encountered an issue where the selected item in the segmented controller needs to move and adjust its position so that no item is hidden when tap or clicked.

With this code, I addressed the issue. Use these 2 functions to create auto-selection.

--

--