Monday, October 12, 2026
HomeiOS Developmentios - Swift expose the protocol to objc in protocol oriented programming

ios – Swift expose the protocol to objc in protocol oriented programming

[ad_1]

I’ve this code which works nicely:

public protocol PermissionProvider {
  static func authorizationStatus(for mediaType: AVMediaType) -> AVAuthorizationStatus
}

extension AVCaptureDevice: PermissionProvider {}

Now I want to reveal the protocol to Objc runtime:

@objc // added this attribute
public protocol PermissionProvider {
  static func authorizationStatus(for mediaType: AVMediaType) -> AVAuthorizationStatus
}

However I acquired an error saying:

AVFoundation.AVCaptureDevice:4:21: error: Goal-C methodology 'authorizationStatusForMediaType:' supplied by methodology 'authorizationStatus(for:)' doesn't match the requirement's selector ('authorizationStatusFor:')
    open class func authorizationStatus(for mediaType: AVMediaType) -> AVAuthorizationStatus

Why is it so?

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments