0

//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

taevanbat
  • 425
  • 1
  • 8
  • 17

1 Answers1

1

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.

Tommy
  • 99,986
  • 12
  • 185
  • 204