I have a custom class with primitive data types as properties. If I create a instance of this class in a static method of another class, the primitive variables are somehow not changeable.
header
@interface CustomClass : NSObject {
double value;
}
@property (nonatomic) double value;
m file
@implementation CustomClass
-(id)init
{
if ((self = [super init]))
{
self.value = 0;
}
return self;
}
Create and return a instance of this class in a static method:
+(CustomClass *)CalculateValue:(double)val{
CustomClass *customClass = [[CustomClass alloc] init];
customClass.value = val;
//The value is not changing after set!!
return [customClass autorelease];
}
If i use an object instead of the primitive variable (eg. NSNumber
) this problem does not occur.