Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Conversation

@crazytonyli
Copy link
Contributor

Description

Almost line-by-line translation of a few reader model types. One and only breaking change is the properties are changed from implicity unwrapped optional to optional.

Testing Details

Should be okay if CI is green.

  • Please check here if your pull request includes additional test coverage.
  • I have considered updating the version in the .podspec file.

@crazytonyli crazytonyli requested a review from mokagio December 8, 2022 04:08
Copy link
Contributor

@mokagio mokagio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

Comment on lines +5 to +20
private let SiteDictionaryFeedIDKey = "feed_ID"
private let SiteDictionaryFeedURLKey = "feed_URL"
private let SiteDictionaryFollowingKey = "is_following"
private let SiteDictionaryJetpackKey = "is_jetpack"
private let SiteDictionaryOrganizationID = "organization_id"
private let SiteDictionaryPrivateKey = "is_private"
private let SiteDictionaryVisibleKey = "visible"
private let SiteDictionaryPostCountKey = "post_count"
private let SiteDictionaryIconPathKey = "icon.img"
private let SiteDictionaryDescriptionKey = "description"
private let SiteDictionaryIDKey = "ID"
private let SiteDictionaryNameKey = "name"
private let SiteDictionaryURLKey = "URL"
private let SiteDictionarySubscriptionsKey = "subscribers_count"
private let SiteDictionarySubscriptionKey = "subscription"
private let SiteDictionaryUnseenCountKey = "unseen_count"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered grouping these in a type?

private enum SiteDictionaryKey {
  static let feedId = "feed_ID"
  static let feedURL = "feed_URL"
  // etc...
}

// Usage
response.number(forKey: SiteDictionaryKey.feedId)

One could go a bit deeper and use enum with cases then add syntax sugar methods on NSDictionary to take away the .rawValue call, so we could write something like:

response.number(forSiteDictionaryKey: .feedId)
response.bool(forSiteDictionaryKey: .following)

...but maybe that's too much overhead and we should save the time to get to a place where we can use modern Swift with Codable sooner. 🤷‍♂️

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be a nicer Swift code for sure. I intentionally tried to keep the re-implementation "boring", or as close to the original Objective-C implementation as possible, for easier review and less risk of introducing bugs. I think, once I've translated the 40 something Objective-C types into Swift, then we can do a proper "swiftification" afterwards?

Base automatically changed from update-nsobject-expecations to trunk December 8, 2022 20:27
crazytonyli and others added 2 commits December 9, 2022 09:35
@crazytonyli crazytonyli enabled auto-merge December 9, 2022 00:13
@crazytonyli crazytonyli merged commit 1baed48 into trunk Dec 9, 2022
@crazytonyli crazytonyli deleted the swift-translation-reader-models branch December 9, 2022 01:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants