Hello everyone,
I cannot change the value of an instance variable inside a function.
I have defined a class:
// 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
I call a function 'myFunction' with parameter temObj which is a NSMyObject instance.
myFunction(temObj);//temObj is NSMyObject
In the function, I can change the value of the instance variable of parameter obj
.
-(void)myFunction:(NSMyObject*) obj;
{
[obj setI:0];
}
... expecting this to change the content of temObj
.
But when I check the results of operation on obj
in function myFunction
the value of temObj.i
has not changed.
Welcome any comment
Thanks