What is the difference between Peer Macro and Member Macro in SwiftMacro?

119 views Asked by At

Why does the Member Macro work in objc code, but the Peer Macro does not?

//MARK: - Member Macro
@ObjCConvertMacro
class TestModel: NSObject, Codable {
    var convertCaseFromOptionalInt: Int?
    // Expand macro
    @objc
    var convertCaseFromOptionalIntObjc: NSNumber? {
        get {
            convertCaseFromOptionalInt as? NSNumber
        }
        set {
            convertCaseFromOptionalInt = newValue?.intValue
        }
    }
}

//MARK: - Peer Macro
class TestModel: NSObject, Codable {
    @ObjCConvertMacro
    var convertCaseFromOptionalInt: Int?
    // Expand macro
    @objc
    var convertCaseFromOptionalIntObjc: NSNumber? {
        get {
            convertCaseFromOptionalInt as? NSNumber
        }
        set {
            convertCaseFromOptionalInt = newValue?.intValue
        }
    }
}

I want to use Swift code in objc by bridging it with a peer macro..

0

There are 0 answers