Passing by reference in Objective-C is the same as passing in C.
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 an
- (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);
Darren Aug 28 '09 at 1:22 2009-08-28 01:22
source share