Swift3 Swift 2.3至Swift 3.0获取成员的模糊参考错误';加入';

Swift3 Swift 2.3至Swift 3.0获取成员的模糊参考错误';加入';,swift3,xcode8,Swift3,Xcode8,我正在将swift 2.3转换为swift 3.0 Swift 2.3代码: extension ContextDidSaveNotification: CustomDebugStringConvertible { public var debugDescription: String { var components = [notification.name] components.append(managedObjectContext.descript

我正在将swift 2.3转换为swift 3.0

Swift 2.3代码:

extension ContextDidSaveNotification: CustomDebugStringConvertible {
    public var debugDescription: String {
        var components = [notification.name]
        components.append(managedObjectContext.description)
        for (name, set) in [("inserted", insertedObjects), ("updated", updatedObjects), ("deleted", deletedObjects)] {
            let all = set.map { $0.objectID.description }.joinWithSeparator(", ")
            components.append("\(name): {\(all)}")
        }
        return components.joinWithSeparator(" ")
    }
}
extension ContextDidSaveNotification: CustomDebugStringConvertible {
    public var debugDescription: String {
        var components = [notification.name]
        components.append(Notification.Name(rawValue: managedObjectContext.description))
        for (name, set) in [("inserted", insertedObjects), ("updated", updatedObjects), ("deleted", deletedObjects)] {
            let all = set.map { $0.objectID.description }.joined(separator: ", ")
            components.append(Notification.Name(rawValue: "\(name): {\(all)}"))
        }
        return components.joined(separator: " ")
    }
}
Swift 3.0代码:

extension ContextDidSaveNotification: CustomDebugStringConvertible {
    public var debugDescription: String {
        var components = [notification.name]
        components.append(managedObjectContext.description)
        for (name, set) in [("inserted", insertedObjects), ("updated", updatedObjects), ("deleted", deletedObjects)] {
            let all = set.map { $0.objectID.description }.joinWithSeparator(", ")
            components.append("\(name): {\(all)}")
        }
        return components.joinWithSeparator(" ")
    }
}
extension ContextDidSaveNotification: CustomDebugStringConvertible {
    public var debugDescription: String {
        var components = [notification.name]
        components.append(Notification.Name(rawValue: managedObjectContext.description))
        for (name, set) in [("inserted", insertedObjects), ("updated", updatedObjects), ("deleted", deletedObjects)] {
            let all = set.map { $0.objectID.description }.joined(separator: ", ")
            components.append(Notification.Name(rawValue: "\(name): {\(all)}"))
        }
        return components.joined(separator: " ")
    }
}
但是我得到了一个错误:对于Swift 3.0代码中的lase返回,对memeber'joined()'的引用不明确

如何解决这个问题?我做了很多研究,但没有找到有效的解决方案

感谢

加入(分隔符:)
是为
数组
声明的,而不是
数组


正如@vadian指出的,
Notification.Name
并不等同于
String
,因此您需要首先转换数组。这应该起作用:

components
  .map({ $0.rawValue })
  .joined(separator: " ")

尝试在组件var初始化中显式声明类型。
Notification.Name
是Swift 3中的一个结构,而不是字符串,这不是
joined()
所期望的