开发者

What does it mean when it says expected expression before UIAccelerationValue?

开发者 https://www.devze.com 2023-02-18 21:20 出处:网络
//this is the code that I\'ve written. It says \"expected expression before UIAccelerationValue\" on the part where it says *accelerateValuesAll = UIAccelerationValue开发者_如何转开发.

//this is the code that I've written. It says "expected expression before UIAccelerationValue" on the part where it says *accelerateValuesAll = UIAccelerationValue开发者_如何转开发.

So, could anybody tell me what the problem is here? How do I fix it?

NSNumber *accelerateValuesALL = UIAccelerationValue.x + UIAccelerationValue.y + UIAccelerationValue.z / 3


NSNumber is a class. You would therefore use it only via explicit messaging, such as:

[accelerateValuesALL floatValue];

Or by implicit Objective-C 2.0 dot notation:

accelerateValuesALL.floatValue;

You appear to want to use a primitive type — that is, one you can use the normal C operators on. So you probably want:

UIAccelerationValue accelerateValuesALL = ...;

Since UIAccelerationValue is a primitive type that UIKit defines for the purposes of passing around acceleration values. It'll just be an alternative name for a float or a double in practice.

0

精彩评论

暂无评论...
验证码 换一张
取 消