简体   繁体   English

“未使用属性访问结果 - 不应将getter用于副作用”警告

[英]“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" 但是,当我尝试初始化加速度计进程时,我收到以下警告:“未使用属性访问结果 - 不应将getter用于副作用”

- (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! 我在第6行得到错误。任何帮助表示赞赏!

This line: 这一行:

self.motionManager.startAccelerometerUpdates;

should be: 应该:

[self.motionManager startAccelerometerUpdates];

Don't use property syntax to call a method. 不要使用属性语法来调用方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何禁用Xcode编译器警告“属性访问结果未使用-吸气剂不应用于副作用” - How to disable Xcode compiler warning “Property access result unused - getters should not be used for side effects” Xcode警告“未使用属性访问结果 - 不应将getter用于副作用” - Xcode warning “Property access results unused - getters should not be used for side effects” 向LocatNotification错误添加变量是未使用属性访问结果-不应将吸气剂用于副作用 - Adding variable to LocatNotification error is Property access result unused - getters should not be used for side effects Objective-C:吸气剂不应用于副作用编译器警告 - Objective-C: Getters should not be used for side effects compiler warning 正确清理物体“吸气剂不应用于副作用” - Clearing an object properly “getters should not be used for side effects” 属性访问结果未使用 - Property access result unused 调用方法时属性访问结果未使用错误 - Property access result unused error while invoking a method xCode:尝试创建密钥窗口时,“未使用属性访问结果” - xCode: “Property access result unused” when trying to make key window NSAssert中使用的变量的未使用变量警告 - Unused variable warning for variable used in NSAssert 如何强制“表达结果未使用”警告发生 - How to force “Expression result unused” warning to happen
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM