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

Re-implement a few remote post related types#559

Merged
crazytonyli merged 3 commits intotranslate-objc-to-swiftfrom
swift-translation-remote-post-types
Dec 16, 2022
Merged

Re-implement a few remote post related types#559
crazytonyli merged 3 commits intotranslate-objc-to-swiftfrom
swift-translation-remote-post-types

Conversation

@crazytonyli
Copy link
Contributor

Description

Similar to #556, this PR is part of re-implementing Objective-C files in Swift.

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

@crazytonyli crazytonyli requested review from a team and jkmassel December 9, 2022 00:08
@crazytonyli crazytonyli force-pushed the swift-translation-remote-post-types branch from d0ff67a to 0d00215 Compare December 9, 2022 00:14
Comment on lines +6 to +12
public static let statusDraft = "draft"
public static let statusPending = "pending"
public static let statusPrivate = "private"
public static let statusPublish = "publish"
public static let statusScheduled = "future"
public static let statusTrash = "trash"
public static let statusDeleted = "deleted" // Returned by wpcom REST API when a post is permanently deleted.
Copy link
Contributor

Choose a reason for hiding this comment

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

I was going to suggest to define a Status enum, but I guess that wouldn't work because of the @objcMembers requirement.

Copy link
Contributor

Choose a reason for hiding this comment

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

Although... I guess we could define the enum in an extension and use it here in the assignment?

extension RemotePost {

  enum Status: String {
     case draft
     case pending
     ...

...

public static let statusDraft = Status.draft.rawValue
public static let statusPending = Status.pending.rawValue
...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, definitely. There are lots of space to make the translated code "more Swift". I'm currently looking into the model's parsing code and in turn may change their property declarations, which kind of relate to your proposal here.

Comment on lines +77 to +79
public override var debugDescription: String {
"\(super.description) (\(allProperties))"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

TIL debugDescription.

The debugger’s po command uses this property to create a textual representation of the object suitable for display in the debugger. The default implemention [sic] returns the same value as description. Override either property to provide custom object descriptions.

@crazytonyli crazytonyli changed the base branch from trunk to translate-objc-to-swift December 15, 2022 21:00
@crazytonyli
Copy link
Contributor Author

I've changed the base branch to the dedicated Swift migration branch, see #562 for more context.

Co-authored-by: Gio Lodi <gio.lodi@automattic.com>
@crazytonyli crazytonyli merged commit 92ccef7 into translate-objc-to-swift Dec 16, 2022
@crazytonyli crazytonyli deleted the swift-translation-remote-post-types branch December 16, 2022 01:03
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.

2 participants