cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Are you an educator? Well we want to hear from you, so check out some tools we think might help you out here!

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Cannot initialize optional DBDownloadUrlTask to nil in Swift 3

Cannot initialize optional DBDownloadUrlTask to nil in Swift 3

DarioJG
Explorer | Level 4

I'm trying to integrate the Objective-C SDK (version 3.0.9) in a Swift 3 project. We could do it with the same project in its Swift 2.3 version.

 

In Swift 3 we get the following error:

nil cannot initialize specified type 'DBDownloadUrlTask?'
    fileprivate var fileDownloadTask: DBDownloadUrlTask? = nil

 

The same line compiled fine in the Swift 2.3 project.

 

Changing the line to:

fileprivate var fileDownloadTask: DBDownloadUrlTask<AnyObject, AnyObject>? = nil

Gets rid of the error, but not sure that is a good solution.

1 Accepted Solution

Accepted Solutions

Re: Cannot initialize optional DBDownloadUrlTask to nil in Swift 3

Greg-DB
Dropboxer
I believe Swift 3 got more strict with its generics, so DBDownloadUrlTask<AnyObject, AnyObject> should be equivalent to DBDownloadUrlTask. It's more explicit, but it should be fine.

View solution in original post

1 Reply 1

Re: Cannot initialize optional DBDownloadUrlTask to nil in Swift 3

Greg-DB
Dropboxer
I believe Swift 3 got more strict with its generics, so DBDownloadUrlTask<AnyObject, AnyObject> should be equivalent to DBDownloadUrlTask. It's more explicit, but it should be fine.

View solution in original post

Poll
We love to learn from the educators who use Dropbox. Whether you teach kids, teens, adults or a combination of all three, we want to know what apps and integrations you use with Dropbox to help with teaching. Which of the ones below is your favorite, or most used tool?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropboxer
What do Dropbox user levels mean?
Need more support?