Issue with conforming to Objective-C protocol from Swift NSObject subclass

前端 未结 2 1126
野的像风
野的像风 2020-12-12 05:20

This piece of code works absolutely fine in Swift 1.1

// Obj-C

@import Foundation;

@protocol HashableObject 
- (NSUInteger)hash;
@end

//          


        
2条回答
  •  时光说笑
    2020-12-12 06:16

    In Swift 1.2 (Xcode 6.3 beta 2) you can override the hash property of NSObject as a computed property:

    class Object: NSObject {
        override var hash: Int {
            return 0
        }
    }
    

提交回复
热议问题