ios - 没有已知的选择器“名称”的类方法-LMLPHP我有两个文件,一个名为CodeInjection.m,内容如下

#import <Foundation/Foundation.h>
#import "Someheaderfile.h"


@interface CodeInjection: NSObject
@end

@implementation CodeInjection

static void __attribute__((constructor)) initialize(void){
    NSLog(@"==== Code Injection in Action====");
    [[CodeInjectionSwift shared] performTask];
}

@end


然后我有一个带有内容的CodeInjectionSwift.swift文件

import Foundation
import NetworkInterceptor

@objc class CodeInjectionSwift: NSObject {
    @objc public static let shared = CodeInjectionSwift()

    override private init(){}

    @objc func performTask(){
        let requestSniffers: [RequestSniffer] = [
            RequestSniffer(requestEvaluator: AnyHttpRequestEvaluator(), handlers: [
                SniffableRequestHandlerRegistrable.console(logginMode: .nslog).requestHandler()
                ])
        ]

        let requestRedirectors: [RequestRedirector] = [
            RequestRedirector(requestEvaluator: DomainHttpRequestEvaluator(domain: "www.antennahouse.com"), redirectableRequestHandler: AlternateUrlRequestRedirector(url: URL(string: "https://www.rhodeshouse.ox.ac.uk/media/1002/sample-pdf-file.pdf")!))
        ]

        let networkConfig = NetworkInterceptorConfig(requestSniffers: requestSniffers,
                                                     requestRedirectors: requestRedirectors)
        NetworkInterceptor.shared.setup(config: networkConfig)
        NetworkInterceptor.shared.startRecording()
    }
}


尝试使用“ CodeInjectionSwift”时,出现这样的错误

ios - 没有已知的选择器“名称”的类方法-LMLPHP

最佳答案

公开@objc func performTask()
@objc public func performTask()

关于ios - 没有已知的选择器“名称”的类方法,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58233526/

10-08 21:05