【问题标题】:What's the equivalent of this statement in swift? [duplicate]swift中这个语句的等价物是什么? [复制]
【发布时间】:2014-12-02 09:47:13
【问题描述】:
id copy = [[[self class] alloc] init];  // Objective-C

// ??? in siwft

swift中的对应物是什么?

【问题讨论】:

    标签: swift copy


    【解决方案1】:

    你在寻找这样的东西吗?

    class foo {
        var bar: Int
        required init() {
            bar = 42
        }
    }
    var a = foo()
    var copy = a.dynamicType()
    

    【讨论】:

    • 如何在 UIView 中使用 swift 实现 NSCopying 协议?
    猜你喜欢
    • 1970-01-01
    • 2018-04-15
    • 1970-01-01
    • 2014-07-29
    • 1970-01-01
    • 1970-01-01
    • 2018-01-21
    • 1970-01-01
    • 2021-06-15
    相关资源
    最近更新 更多