objective c - trouble with getter method in Xcode -
i having trouble getter method when try point person touched screen.
in .h file, have property
@property(nonatomic, assign)cgpoint touchlocation;
in .m file, have following code
@synthesize touchlocation=_touchlocation; -(void)usertouchlocation { recognizer=[[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(locationpressedcoordinates:)]; [recognizer setnumberoftapsrequired:1]; [self.view addgesturerecognizer:recognizer]; } -(void)locationpressedcoordinates:(uitapgesturerecognizer *)rec { cgpoint loc= [rec locationinview:rec.view]; [self settouchlocation:loc]; } -(void)settouchlocation:(cgpoint)touchlocation { _touchlocation=touchlocation; } -(cgpoint)touchlocation { return _touchlocation; }
however when try , location doing cgpoint foo=[self touchlocation]; returns point (0,0). if use nslog statement debug program, setter method works, getter method not.
Comments
Post a Comment