代码之家  ›  专栏  ›  技术社区  ›  LancDec

ParseSwift.initialize显示无法转换类型错误的值

  •  0
  • LancDec  · 技术社区  · 5 年前

    我认为是时候开始使用Swift了,所以我正在对obj C应用程序进行完全重写。此应用程序使用解析服务器和CocoaPods。按照我添加的AppDelegate.swift中的ParseSwift文档示例

    import ParseSwift
    
    class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate {
    
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
            
            ParseSwift.initialize(applicationId: "AppID", clientKey: "", serverURL: URL(string: "https://server")!, liveQueryServerURL: URL(string: "https://server")!, authentication: ((URLAuthenticationChallenge,(URLSession.AuthChallengeDisposition,URLCredential?) -> Void) -> Void))
    

    等等。。。但是初始化行显示错误

    无法转换类型“”的值((URLAuthenticationChallenge,(URLSession.AuthChallengeDisposition,URLCredential?)->无效)->无效)。键入“到预期的参数类型”((URLAuthenticationChallenge,(URLSession.AuthChallengeDisposition,URLCredential?)->无效)->无效)?”

    0 回复  |  直到 5 年前
        1
  •  1
  •   CoreyB    5 年前

    身份验证是一个可选字段,因此您不需要传递值。

    如果你没有对身份验证做任何事情(大多数情况下),你不应该传递任何东西:

    ParseSwift.initialize(applicationId: "AppID",
                         clientKey: "",
                         serverURL: URL(string: "https://server")!)
    

    当您计划使用身份验证进行证书固定时,您应该将其用作尾随闭包:

    ParseSwift.initialize(applicationId: "AppID",
                         clientKey: "",
                         serverURL: URL(string: "https://server")!) { (challenge, credential) in
                credential(.performDefaultHandling, nil)
            }