[英]NSDictionary with contents of file in Swift 2
In Swift 1.X 在Swift 1.X中
let dict:AnyObject = NSDictionary(contentsOfFile: pathURL)!
was working. 在工作。 Since Swift 2 I get a " Type of expression is ambiguous without more context ".
从Swift 2开始,我得到了一个“ 表达式类型是模棱两可的,没有更多上下文 ”。 I searched a lot, but can't figure out whats missing.
我进行了很多搜索,但找不到丢失的内容。
I suspect that pathURL
is of type NSURL
. 我怀疑
pathURL
是NSURL
类型。 contentsOfFile
expects a String
. contentsOfFile
需要一个String
。 In that case you might try: 在这种情况下,您可以尝试:
let dict:AnyObject = NSDictionary(contentsOfFile: pathURL.path!)!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.