Pass-by-reference in Objective-C is the same as it is in C.
The equivalent to the following C# code:
void nullThisObject(ref MyClass foo)
{
foo = null;
}
MyClass bar = new MyClass();
this.nullThisObject(ref bar);
assert(bar == null);
is
- (void)nilThisObject:(MyClass**)foo
{
[*foo release];
*foo = nil;
}
MyClass* bar = [[MyClass alloc] init];
[self nilThisObject:&bar];
NSAssert(bar == nil);
and
- (void)zeroThisNumber:(int*)num
{
*num = 0;
}
int myNum;
[self zeroThisNumber:&myNum];
NSAssert(myNum == 0);