What's Objective-C's equivalent of Swift's inout Parameters?

Viewed 3628

I'm back on writing Objective-C code again and is trying to find the equivalent of Swift's inout parameter notation in Objective-C.

func swapTwoInts(_ a: inout Int, _ b: inout Int) {
    let temporaryA = a
    a = b
    b = temporaryA
}

https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Functions.html#//apple_ref/doc/uid/TP40014097-CH10-ID158

So far I've learned: 1.inout is not objc-compatible. 2.objc simply doesn't have language feature like this.

However, when I'm designing my API, I want it to be clear that this method is modifying its parameter. Is there any good way to accomplish this in Objective-C? Thank you!

1 Answers
Related