Unable to access class member inside the pod

扶醉桌前 提交于 2019-12-11 04:19:08

问题


Im accessing a variable inside a class of my pod. The members inside the class have internal access modifier. But cannot able to access the tenantURL from the networking class. Why this happens?

SDKCore class

public class SDKCore {

    public static let shared = SDKCore()

    var accessToken: String
    var tenantURL: String
    var clientSecret: String
    var appId: String

    init(accessToken: String, tenantUrl: String, clientSecret: String, appId: String) {
        self.accessToken = accessToken
        self.tenantURL = tenantUrl
        self.clientSecret = clientSecret
        self.appId = appId
    }

    static var getInstance: ApiClient = {
        return ApiClient()
    } ()
}

Networking class

class Networking {

    func performFileDownload(path: String, completionHandler: @escaping (ResultModel<DataResponse<Data>, Error>) -> Void) {
        let fileUrl = SDKCore.tenantURL + path

        alamofire.request(fileUrl)
            .responseData { (response) in
                switch response.result {
                case .success(_):
                    completionHandler(.success(response))
                case .failure(let error):
                    completionHandler(.failed(error))
                }
        }
    }

Use of unresolved identifier 'SDKCore'


回答1:


If you look at your code, it clearly visible that tent tenantURL is instance variable not the class one,

SDKCore.shared.tenantURL

Also Try to clean your project and reinstall the pods



来源:https://stackoverflow.com/questions/54237149/unable-to-access-class-member-inside-the-pod

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!