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

时间:2016-12-21 00:38:04

标签: swift swift3 dropbox-api

我对API已经完全陌生了,并且正在关注appcoda https://www.appcoda.com/dropbox-api-tutorial/

它进展顺利,但我遇到了一个问题,并且鉴于我是一个新手,我不知道如何修复它的第一个线索。

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.

        let appKey = "n00nzv68gtxk6c9"      // Set your own app key value here.
        let appSecret = "itumv0icksr7yj6"   // Set your own app secret value here.

        let dropboxSession = DBSession(appKey: appKey, appSecret: appSecret, root: kDBRootDropbox)
        DBSession.setShared(dropboxSession)

        return true

        if DBSession.sharedSession().handleOpenURL(url) {
            if DBSession.shared().isLinked() {
                NotificationCenter.defaultCenter.postNotificationName("didLinkToDropboxAccountNotification", object: nil)
                return true
            }
        }

        return false

    }

问题出在

if DBSession.sharedSession().handleOpenURL(url) {

我收到错误

Use of unresolved identifier 'url'

我需要做什么?

1 个答案:

答案 0 :(得分:0)

根据教程,您需要在AppDelegate.swift中使用正确的委托方法

// handle custom application schemes
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool {
    if DBSession.sharedSession().handleOpenURL(url) {
        print("Url defined as \( url)")
    }
}