使用未解析的标识符 'url'
Use of unresolved identifier 'url'
我是 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'
我需要做什么?
根据教程,您需要在 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)")
}
}
我是 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'
我需要做什么?
根据教程,您需要在 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)")
}
}