【问题标题】:How to use Octokit in Swift3 ?如何在 Swift3 中使用 Octokit?
【发布时间】:2017-02-27 07:00:51
【问题描述】:

我第一次使用Octkit,我用cocoapods安装,但是它不起作用,正如GitHub中解释的那样:https://github.com/nerdishbynature/octokit.swift

所以我尝试用这种方式实现代码;

let token = GithubAPIManager.sharedInstance.OAuthToken
    let config = TokenConfiguration(token)

    Octokit(config).me() { response in

        switch response {

        case .Success(let user):

        case .Failure(let error):

        }
    }

但是当我添加TokenConfiguration 时出现错误提示

使用未解析的标识符

对于Octkit(config) 也有错误。我导入了 Octokit 和 Foundation。怎么了?

【问题讨论】:

    标签: swift cocoapods octokit


    【解决方案1】:

    解决方案非常简单(有同样的问题):在示例中,对枚举的引用不正确,另外 println 在 Swift 3 中不再可用。

    .success 和 .failure 需要小写。如果您想像自述文件中的示例一样打印,请使用 print 而不是 println。

    let token = GithubAPIManager.sharedInstance.OAuthToken
    let config = TokenConfiguration(token)
    
    Octokit(config).me() { response in
    
        switch response {
    
        case .success(let user):
    
        case .failure(let error):
    
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2017-04-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-21
      • 2023-02-12
      相关资源
      最近更新 更多