无法访问窗格中的班级成员 [英] Unable to access class member inside the pod

查看:83
本文介绍了无法访问窗格中的班级成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在访问 pod class 内的变量。类中的成员具有内部访问修饰符。但是无法从网络类访问tenantURL。为什么会发生这种情况?

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类

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()
    } ()
}

网络课程

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))
                }
        }
    }




使用未解析的标识符'SDKCore'

Use of unresolved identifier 'SDKCore'

推荐答案

如果您查看代码, ,可以清楚地看到tent tenantURL是实例变量,而不是第一个类

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

SDKCore.shared.tenantURL

也请尝试清理项目并重新安装Pod

Also Try to clean your project and reinstall the pods

这篇关于无法访问窗格中的班级成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆