Modernize to Swift 5 and add unit tests#1
Open
umarF wants to merge 1 commit into
Open
Conversation
Bring this 2017-era Swift 3 project up to modern standards. The code no longer compiled on current Xcode because it relied on APIs that have since been renamed or removed. Source modernization: - Replace removed/renamed APIs: NSFontAttributeName/NSForegroundColorAttributeName -> NSAttributedString.Key, UITableViewAutomaticDimension -> UITableView.automaticDimension, UIApplicationLaunchOptionsKey -> UIApplication.LaunchOptionsKey, .index(where:) -> .firstIndex(where:). - `protocol sectionTappedDelegate: class` -> `SectionTappedDelegate: AnyObject`. - Give TeamModel/LeagueModel real initializers (memberwise + dictionary) and synthesized Equatable/Hashable, replacing the mutating setEmptyObject/setTeams helpers and the hand-rolled isEqual* free functions. - Extract all selection bookkeeping out of the view controller into a pure, UIKit-independent MultiSelectionModel. Selection is now tracked by position instead of by value, fixing a latent bug where equal teams in different sections were treated as the same selection. - Slim MultiApprovalController down to a thin table-view layer. Project modernization: - Swift 3.0 -> 5.0, iOS deployment target 10.3 -> 13.0, objectVersion 46 -> 56. - Add a .gitignore for Xcode/SwiftPM artifacts and per-user data. Tests: - Add a MultiSelectHeaderTests logic-test target with a shared scheme. - Cover the model initializers/equality and the full selection state machine (single toggle, section toggle, header auto-selection, positional selection, ordering, and empty/out-of-range edge cases). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uhsa6djvaVngWNbG56ZQyx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This project was written in Swift 3.0 (2017, Xcode 8.3, iOS 10.3) and no longer compiled on modern Xcode because it depended on APIs that have since been renamed or removed. This PR modernizes the code to Swift 5 / iOS 13+, refactors the models and selection logic, and adds a unit-test target.
Source modernization
NSFontAttributeName/NSForegroundColorAttributeName→NSAttributedString.KeyUITableViewAutomaticDimension→UITableView.automaticDimensionUIApplicationLaunchOptionsKey→UIApplication.LaunchOptionsKey.index(where:)→.firstIndex(where:)protocol sectionTappedDelegate: class→SectionTappedDelegate: AnyObject.TeamModel/LeagueModelnow have real initializers (memberwise + dictionary) and synthesizedEquatable/Hashable, replacing the mutatingsetEmptyObject/setTeams/setLeaguehelpers and the hand-rolledisEqualTeamModel/isEqualLeagueModelfree functions.MultiSelectionModel.MultiApprovalControlleris now a thin table-view layer.Behavioural fix
The original code tracked selection by value (
isEqualTeamModel), so two teams that compared equal in different sections were treated as one selection.MultiSelectionModeltracks selection by position (section,row), so each row is independent. A section header is selected only when every row in it is selected.Project modernization
3.0→5.0, iOS deployment target10.3→13.0,objectVersion46→56..gitignorefor Xcode / SwiftPM build artifacts and per-user data.Tests
Added a
MultiSelectHeaderTestslogic-test target (with a shared scheme) covering:Run with
Cmd+Uor:Verification note
This PR was prepared in a Linux environment with no Xcode/Swift toolchain, so it was not compiled or run here. Changes were made against the public UIKit/Swift 5 API surface, and the modified
project.pbxprojwas validated for balanced structure and no dangling object references. Please run a build + the test target in Xcode/CI before merging.🤖 Generated with Claude Code
Generated by Claude Code