hey there,
im very new to objective c programming, and i'm having trouble getting the values contained in a class to change. ill just go straight to the problem
so basically i created a class called vector that contains variables like this:
now, i have this function that is supposed to set a vector inside Vector.m. this is what it looks like:
but when i say
(xfloat and yfloat do have a value, i have confirmed this)
when i output vector1.X and vector1.Y i get 0 and 0...whats going on?
let me know if this is not clear
im very new to objective c programming, and i'm having trouble getting the values contained in a class to change. ill just go straight to the problem
so basically i created a class called vector that contains variables like this:
Code:
Vector.h:
@interface Vector : NSObject {
float X;
float Y;
float magnitude;
float direction;
}
@property float X;
@property float Y;
@property float magnitude;
@property float direction;
- (Vector *)setVector:(float *)newX : (float *)newY;
Vector.m:
#import "Vector.h"
@implementation Vector
@synthesize X;
@synthesize Y;
@synthesize magnitude;
@synthesize direction; //goes on for a while this is just the beginning
now, i have this function that is supposed to set a vector inside Vector.m. this is what it looks like:
Code:
- (Vector *) setVector:(float *)newX : (float *)newY{
Vector *v1;
v1.X = *newX;
v1.Y = *newY;
v1.magnitude = sqrtf(powf(X,2) + powf(Y, 2));
v1.direction = atanf(Y/X);
return v1;
}
Code:
vector1 = [vector1 setVector: &xfloat : &yfloat];
when i output vector1.X and vector1.Y i get 0 and 0...whats going on?
let me know if this is not clear