简体   繁体   English

无法调用非函数类型“URL”的值

[英]Cannot call value of non-function type 'URL'

I am following The Complete iOS App Development Bootcamp by Angela, and I am in lesson 353 .我正在关注 Angela 的完整 iOS 应用程序开发训练营,我在第 353课。 My question is how to solve the error "Cannot call value of non-function type 'URL'".我的问题是如何解决错误“无法调用非函数类型'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.当我在 Xcode 11.3.1 上时,讲师在 Xcode 10 Beta 上没有遇到问题,但我在遵循完全相同的代码时遇到了问题。 Anyone knows how to solve it?任何人都知道如何解决它?

Most likely somewhere you defined a variable like this:您很可能在某个地方定义了这样的变量:

在此处输入图像描述

hence you are overwriting a URL class (an instance of which you are trying to create), with your local variable.因此,您将使用局部变量覆盖URL class (您尝试创建的实例)。

Change your local variable to lower-case (which is Swift standard anyways), and it will work:将您的局部变量更改为小写(无论如何都是 Swift 标准),它将起作用:

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"))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM