Cannot call value of non-function type 'URL'

1k views Asked by At

I am following The Complete iOS App Development Bootcamp by Angela, and I am in lesson 353. My question is how to solve the error "Cannot call value of non-function type 'URL'". My code so far is simply of three lines

import Cocoa
import CreateML

let data = try MLDataTable(contentsOf: URL(fileURLWithPath: "/Users/user/Documents/CurrentProjects/Work/Mini/Twittermenti-iOS13-master/twitter-sanders-apple3.csv"))

The instructor is not facing the problem on Xcode 10 Beta while I am on Xcode 11.3.1 but I face the problem while following the exact same code. Anyone knows how to solve it?

1

There are 1 answers

0
timbre timbre On

Most likely somewhere you defined a variable like this:

enter image description here

hence you are overwriting a URL class (an instance of which you are trying to create), with your local variable.

Change your local variable to lower-case (which is Swift standard anyways), and it will work:

import Cocoa
import CreateML

var url: URL

let data = try MLDataTable(contentsOf: URL(fileURLWithPath: "/Users/user/Documents/CurrentProjects/Work/Mini/Twittermenti-iOS13-master/twitter-sanders-apple3.csv"))