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 8186239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:07:34+00:00 2026-06-07T02:07:34+00:00

I’m rather new to Objective-C and iOS development, and after having read some of

  • 0

I’m rather new to Objective-C and iOS development, and after having read some of the documentation on the Accelerometer class I’m still not sure about a few things so maybe you can clarify these for me.. Also please excuse my C++.. I’m only using it as an example..

I want to create a while-loop that looks smith like this:

while(play)
{
    while(getYaxis()>=..... && getYaxis()<=....)
    {
        //do something..
    }
    //more code to execute...
}

I want to create a method called “getYaxis” that returns the force exercised on the Y-axis of the accelerometer at the moment the method is called…

Is this possible and how? Apparently you can set the Accelerometer to return g values at regular intervals, where as I only want to have a single value returned the “second” I ask for it in my while-condition. Then the rest of the code should be executed as shown above and at some point I will return to that while-loop and check the Y-value again. In other words, rather than setting an interval regarding how often to check the accelerometer value, I want to let that interval be the time it takes to execute the rest of the code and come back to the while loop that will be checking the Y-value again.. Or is this interval between the two checks so short that could cause problems eventually?

Thanks!

  • 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-07T02:07:35+00:00Added an answer on June 7, 2026 at 2:07 am

    Here is how you get the Accelerometer and become the delegate:

    UIAccelerometer *theAccelerometer = [UIAccelerometer sharedAccelerometer];
    theAccelerometer.updateInterval = 0.001; //in seconds
    theAccelerometer.delegate = self;
    

    Remember to add <UIAccelerometerDelegate> to your VC.

    Then you can catch the changes in:

    -(void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
    
    {
        self.x = acceleration.x;
        self.y = acceleration.y;
        self.z = acceleration.z;
    }
    

    Make sure you have properties created for x,y,z of the type UIAccelerationValue.

    Then just write a method called getX or getY;

    -(UIAccelerationValue *) getY
    {
        return self.y;
    }
    

    You will have it updating very millisecond or however fast you want, and saving it in a property. Then you can check the property’s value with the function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I am doing a simple coin flipping experiment for class that involves flipping a
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm having trouble keeping the paragraph square between the quote marks. In firefox the

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.