class BFCommon {
class BFUser {
}
extension BFUser {
static func sayHello() {
print("Hello")
}
}
}
BFCommon.BFUser.sayHello
Need help fixing my code to call a function like so.
BFCommon.BFUser.sayHello
答案 0 :(得分:1)
Exactly as the error message suggests, extensions can only be declared at the file scope:
class BFCommon {
class BFUser {}
}
extension BFCommon.BFUser {
static func sayHello() {
print("Hello")
}
}
BFCommon.BFUser.sayHello()