【发布时间】:2016-12-21 00:38:03
【问题描述】:
我对 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'
我需要做什么?
【问题讨论】:
-
您需要在尝试使用之前正确声明并初始化一个名为
url的变量,或者您需要将url替换为另一个URL类型变量。 -
应该是什么类型的?
-
另请注意,
if DBSession...块与您放入的委托方法完全不同。 -
“它应该是什么类型?” - 转到
DBSession类的文档页面并查看handleOpenURL方法的信息。它会告诉你它应该是什么类型。 -
@rmaddy 我不明白你的意思:“另请注意,if DBSession... 块与您放入的委托方法完全不同”
标签: swift swift3 dropbox-api