Swift 语法错误

Swift Errors with syntax

有人可以帮我解决这些错误吗? Swift 已更改,我不知道如何更改这些以使其适用于新版本:

这个报错如下:

Cannot invoke createDirectoryAtPath with an argument list of type (SwiftCoreDataHelper.Type, withintermediateDirectories: Bool, atrributes: NilLiteralConvertible, error:inout NSError?)

NSFileManager.defaultManager().createDirectoryAtPath(SwiftCoreDataHelper, withIntermediateDirectories: true, attributes: nil, error: &error)

下一对告诉我 'error' 是一个额外的参数:

if storeCoordicator.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: nil, error: &error){
        if (error != nil){
            print(error!.localizedDescription)
            abort()
        }
    }

let items: NSArray = managedObjectContext.executeFetchRequest(fetchRequest, error: nil)

在Swift2中,需要用do-catch块来捕获错误; 将 addPersistentStoreWithType 与 CoreData 一起使用时,您需要执行以下操作:

do
{
    try storeCoordinator.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: url, options: nil)
}
catch(let error as NSError)
{
    NSLog(error.localizedDescription) //error has occurred.
    abort() //abort
}

同样适用于executeFetchRequest:

do
{
    let items: NSArray = try managedObjectContext.executeFetchRequest(fetchRequest)
}
catch(let error as NSError)
{
    NSLog(error.localizedDescription)
}

createDirectoryAtPath一样:

do
{
    try NSFileManager.defaultManager().createDirectoryAtPath(SwiftCoreDataHelper, withIntermediateDirectories: true, attributes: nil)
}
catch(let error as NSError)
{
    NSLog(error.localizedDescription)
}