cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Share your feedback on the Document Scanning Experience in the Dropbox App right 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: 

Re: Cannot initialize optional DBDownloadUrlTask to nil in Swift 3

Cannot initialize optional DBDownloadUrlTask to nil in Swift 3

DarioJG
Explorer | Level 4
Go to solution

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

Greg-DB
Dropbox Staff
Go to solution
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

Greg-DB
Dropbox Staff
Go to solution
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.
Need more support?