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

Could be the purchase delegate exists without marking it as Objc and not inherent from NSObject (for example AnyObject) #4066

Open
jesus-mg-ios opened this issue Jul 16, 2024 · 2 comments

Comments

@jesus-mg-ios
Copy link

@objc(RCPurchasesDelegate) public protocol PurchasesDelegate: NSObjectProtocol {

Currently, when implementing delegates in Swift for classes that interact with Objective-C, delegates often need to inherit from NSObject and be marked with @objc. This requirement adds boilerplate and limits flexibility, especially when designing Swift-first APIs. This proposal suggests allowing delegates to conform to AnyObject instead, providing more flexibility and aligning with Swift conventions.

Details:

  • Current Limitation: Delegates must inherit from NSObject and be annotated with @objc to work with Objective-C interoperability.
  • Proposed Solution: Extend interoperability to delegates conforming to AnyObject, maintaining compatibility with Objective-C while embracing Swift conventions.

Benefits:
Simplifies API design by reducing boilerplate (@objc and NSObject inheritance).
Enables better alignment with Swift's type system and safety features.
Allow clients not expose strings paths inside the binary (that happens if you have to inherit from NSObject)

@RCGitBot
Copy link
Contributor

👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

@aboedo
Copy link
Member

aboedo commented Jul 17, 2024

this is a great idea, we should modernize the delegate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants