简体   繁体   中英

“Property access result unused - getters should not be used for side effects” warning

I am trying to start the accelerometer and send a message to the user based on the accelerometer's data values. However, when I am trying to initialize accelerometer processes, I get the following warning: "Property access result unused - getters should not be used for side effects"

- (void)viewDidLoad
{
[super viewDidLoad];
self.motionManager = [[CMMotionManager alloc] init];
self.motionManager.accelerometerUpdateInterval = 0.04;
self.motionManager.startAccelerometerUpdates;
[self.motionManager startAccelerometerUpdatestoQueue:[NSOperationQueue current
Queue] withHandler:^(CMAccelerometerData *accelerometerData, NSError *error)

I get the error on line 6. Any help is appreciated!

This line:

self.motionManager.startAccelerometerUpdates;

should be:

[self.motionManager startAccelerometerUpdates];

Don't use property syntax to call a method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM