Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace all ContextManager sharedInstance() usages with shared #24187

Merged
merged 2 commits into from
Mar 11, 2025

Conversation

mokagio
Copy link
Contributor

@mokagio mokagio commented Mar 11, 2025

Apart from being more Swift-y, this will also allow us to differentiate between a shared instance for the Objective-C layer (CoreDataStack) and one for the Swift layer (CoreDataStackSwift).

This differentiation will be valuable if/when we'll replace ContextManager references with CoreDataStack/CoreDataStackSwift so that WordPressDataObjC can refer to the functionality without knowing about ContextManager, which is defined in the Swift WordPressData layer.

For example, the Objective-C AbstractPost implementation references the Swift ContextManager implementation

[[ContextManager sharedInstance] saveContext:self.managedObjectContext];

I'm doing this change in a dedicated PR because there are 100+ usages of sharedInstance and because I don't know yet where the work of replacing ContextManager access with CoreDataStack in the Objective-C layer will bring me...

Testing

This is just a simple swap, given that shared wraps sharedInstance(). If the code compiles, we should be good.

I still gave the app a run on my device and loaded a few screens just to ensure it runs okay.


Part of #24165

Apart from being more Swift-y, this will also allow us to differentiate
between a shared instance for the Objective-C layer (`CoreDataStack`)
and one for the Swift layer (`CoreDataStackSwift`). This differentiation
will be valuable if/when we'll replace `ContextManager` references with
`CoreDataStack`/`CoreDataStackSwift` so that WordPressDataObjC can
refer to the functionality without knowing about `ContextManager`, which
is defined in the Swift WordPressData layer.
@mokagio mokagio added this to the 25.9 milestone Mar 11, 2025
@mokagio mokagio added the Core Data Issues related to Core Data label Mar 11, 2025
@wpmobilebot
Copy link
Contributor

wpmobilebot commented Mar 11, 2025

WordPress Alpha📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
App NameWordPress Alpha WordPress Alpha
ConfigurationRelease-Alpha
Build Numberpr24187-59884f7
Version25.8
Bundle IDorg.wordpress.alpha
Commit59884f7
App Center BuildWPiOS - One-Offs #11631
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Mar 11, 2025

Jetpack Alpha📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
App NameJetpack Alpha Jetpack Alpha
ConfigurationRelease-Alpha
Build Numberpr24187-59884f7
Version25.8
Bundle IDcom.jetpack.alpha
Commit59884f7
App Center Buildjetpack-installable-builds #10662
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@mokagio mokagio requested review from crazytonyli and kean and removed request for crazytonyli March 11, 2025 20:17
@mokagio mokagio added this pull request to the merge queue Mar 11, 2025
Merged via the queue into trunk with commit 33a7bdf Mar 11, 2025
25 checks passed
@mokagio mokagio deleted the mokagio/sharedInstance-shared branch March 11, 2025 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core Data Issues related to Core Data
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants