Swift: How to call non-class function if I have th

2019-09-18 03:34发布

This question already has an answer here:

I know that I can just change names, but is there another way to solve this?

class MyClass{
    func print(_ string: String) {
        // I'm trying to call a native print method.
        // Results in error, because it's trying to do recursion.
        print(string, terminator: ";")
    }
}

标签: swift swift3
1条回答
Deceive 欺骗
2楼-- · 2019-09-18 03:55

For global Swift builtins you can call Swift.whatever(argument), so in this case:

Swift.print(string, terminator: ";")
查看更多
登录 后发表回答