Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8190379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:36:35+00:00 2026-06-07T03:36:35+00:00

Based on this documentation, the CMAccelerometerData class (found in the Core Motion framework) has

  • 0

Based on this documentation, the CMAccelerometerData class (found in the Core Motion framework) has a property of type CMAcceleration called acceleration that is a typedef of a struct containing 3 values (double x, double y, double z)

I’m rather new to Objective-C (I only know C++..) so my question is this : How do I access, let’s say the double y value kept in that property, at some point during my code?

Do I first create an instance of the CMAccelerometerData class like this :

CMAccelerometerData *myAccelerometer;

then access its acceleration property :

double axisYvalue = [myAccelerometer acceleration]; 

the above is obviously wrong, isn’t it? I have to get the Y found in acceleration specifically so how do I do that?

double axisYvalue = [myAccelerometer acceleration->y]; // no this is wrong as well..

so how do I do it?

And one last question if I may 🙂

given this specific class and property that I mentioned.. and let’s say I’ve instantiated my CMAccelerometer class.. Now every time, during my code, I use something like

return [myAccelerometer acceleration->y]; // let's say that's the correct version :)

inside some -(double) method .. will I be getting the value of the Y-axis at that specific moment in which the call is being made ?

I am asking this because I got confused when reading about the now deprecated UIAccelerometer class where you had to define intervals and update the values of x,y,z every so often etc..
where as now I can get the value that is being exercised on the Y-axis the moment the call to the acceleration property is made, isn’t that the case?

phew… sorry for the length of this text! 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T03:36:37+00:00Added an answer on June 7, 2026 at 3:36 am

    Coming from C++, I assume it’s safe to assume that you understand pointers. That first line:

    CMAccelerometerData *myAccelerometer;
    

    …isn’t creating an instance, it’s declaring a pointer to an instance, which won’t point to anything valid. To get a valid instance, you’ll never actually create one of these yourself. Instead, you’ll use the CMMotionManager class’ accelerometerData property to get a pointer to a valid object:

    // Sometime earlier...
    CMMotionManager* manager = [[CMMotionManager alloc] init];
    [manager startAccelerometerUpdates];
    
    // Sometime in the present...
    // Get a ref to the most recent accelerometer data.
    CMAccelerometerData* data = [manager accelerometerData];
    
    // Access it.
    double x = [data acceleration].x;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Based on this documentation , I've implemented a catch all route which routes to
I am trying to train cascade based on this post and official documentation. My
I'm writing my first jQuery plugin based on this documentation and I have a
Based on this article I was able to get the FullName to work rather
Based on this question I've created a small application which is catching all debug
Based on this , how would you make ignoring parameters more succint? var m
Based on this question I understand the purpose of the construct in linking C
Based on this question How to insert array into mysql using PDO and bindParam?
Based on this SO post , and this example , I expect that, when
Sorry for this based question. I am fresh to jqplot and would like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.