下面的Swift 2示例给出了以下错误:
String类型的值没有成员'stringByAppendingPathComponent'

我需要为Swift 3更改什么?
试图在Swift 3中获取默认文档目录,但表示已将其重命名为FileManager.如果更新到FileManager然后得到错误:无法调用非函数类型FileManager的值
Xcode 8. Swift 3 Beta 4.
使用FMDB Swift指令中的这一行代码:
let documents = try! NSFileManager.defaultManager().URLForDirectory(.DocumentDirectory, inDomain: .UserDomainMask, appropriateForURL: nil, create: false)
Run Code Online (Sandbox Code Playgroud) 使用自定义swift类(不是主ViewController)
import Foundation
class Myclass: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet var tableView: UITableView!
var items: [String] = ["Item1", "Item2", "Item3"]
override func viewDidLoad() {
self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "td")
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.items.count;
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell:UITableViewCell = self.tableView.dequeueReusableCell(withIdentifier: "td")! as UITableViewCell
cell.textLabel?.text = self.items[indexPath.row]
return cell
}
func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) {
print("You selected cell #\(indexPath.row)!")
}
}
Run Code Online (Sandbox Code Playgroud)