ios - Passing a value to a UIView returns nil -


i have uiviewcontroller gameplayviewcontroller , uiview joystickview.

im trying set float value joystickview.

in gameplayviewcontroller.m

joystickview *joystick = [[joystickview alloc] initwithframe:cgrectmake(0, 0, 100, 100)];  joystick.velocity = 123.0f; [self.view addsubview:joystick]; 

in joystickview.h

@property(nonatomic) float velocity; 

.m

@synthesize velocity; -(id)initwithframe:(cgrect)frame { self = [super initwithframe:frame]; if (self) {     nslog(@"%f", velocity);        //output 0 } return self; } 

what missing?

you can override initwithframe creating initwithframeandvelocity method

-(id)initwithframe:(cgrect)frame andvelocity:(float)v { self = [super initwithframe:frame]; if (self) { velocity = v;     nslog(@"%f", velocity);        //output 0 } return self; } 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -