call function and change value of parameter

Posted by user262325 on Stack Overflow See other posts from Stack Overflow or by user262325
Published on 2010-06-17T11:47:10Z Indexed on 2010/06/17 11:53 UTC
Read the original article Hit count: 166

Filed under:

Hello everyone

I have constructed one object:

//  info.h


#import <Foundation/Foundation.h>


@interface NSMyObject : NSObject 
{

    NSInteger i;

}

-(void) setI:(NSInteger)v;
 @end

#import "info.h"


@implementation NSMyObject


-(void) setI:(NSInteger)v ;
{
    i=v;    
}

- (void)dealloc {


    [super dealloc];
}

@end

Is it possible I call a function 'myFunction' with parameter temObj (NSMyObject)

myFunction(temObj);//temObj is NSMyObject

in the function I can change the content of parameter obj

-(void)myFunction:(NSMyObject*) obj;
{


    [obj setI:0];

}

then I hope the content of temObj also can be changed.

But I check the operation on obj in function myFunction can not affect temObj where I call myFunction.

Welcome any comment

Thanks

© Stack Overflow or respective owner

Related posts about iphone