Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift 3: NSURL to URL missing init?

Tags:

url

swift

nsurl

I just used XCode 8 and let it convert my existing project. Now I face the error that there is no init function for new URL without parameters.

class fileObj : NSObject, NSCopying, Comparable {
    var URL                   = NSURL()    // initial
...

The new code looks like:

class fileObj : NSObject, NSCopying, Comparable {
    var myUrl                 = Foundation.URL()    // initial
...

How should I init the new URL var?

like image 464
Peter71 Avatar asked Mar 12 '23 03:03

Peter71


1 Answers

it makes absolutely zero sense to do so, but currently (Swift3, Xcode Version 8.0 (8A218a)) it is working and gives you a totally blank URL object with no purpose at all, as you just asked for.

var myURL: URL = NSURLComponents().url!
like image 139
holex Avatar answered Mar 20 '23 15:03

holex