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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:29:24+00:00 2026-06-02T18:29:24+00:00

If the event handler for Accelerometer takes a UIAcceleration * in the following: -(void)

  • 0

If the event handler for Accelerometer takes a UIAcceleration * in the following:

-(void) accelerometer:(UIAccelerometer *)accelerometer 
            didAccelerate:(UIAcceleration *)acceleration {

then if ViewController has an instance variable:

UIAcceleration accelerationCurrent;

Then in order to remember the acceleration as a current state, I used

accelerationCurrent = *acceleration;

in the Accelerometer event handler. But the instance variable declaration in the .h file gave error as “Interface type cannot be statically allocated”.

I thought UIAcceleration is just 3 doubles: x, y, z, so if we can use CGPoint aPoint there, how come we cannot use UIAcceleration accelerationCurrent, and how can we keep the acceleration without copying the x, y, z individually but use one UIAcceleration object? (if we declare a pointer instead, and copy the pointer (the reference), then upon leaving the accelerometer event handler, the pointer may point to an illegal memory space).

  • 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-02T18:29:26+00:00Added an answer on June 2, 2026 at 6:29 pm

    Even though UIAcceleration has only four data members (x, y, z, and a timestamp) it is not a struct, and therefore it does not let you refer to it statically (i.e. you need to use a pointer). This is in contrast to CGPoint, which is a C struct, so you can use it both through a pointer or without a pointer.

    Unfortunately, there is no way around copying the values in which you are interested: you are absolutely right that once the thread leaves your handler, UIAcceleration object may get reused behind your back. UIAcceleration does not conform to copying protocol either, so you would need to write that copy routine yourself.

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

Sidebar

Related Questions

My event handler looks like this: private void List_KeyPress(object sender, KeyPressEventArgs e) I saw
I have an 'onclick' event handler for a div and the div has a
At btnSave - button event-handler, in the following two lines, SelectedValue is always returning
I have declared a generic event handler public delegate void EventHandler(); to which I
I have a gridview event OnRowDataBound event handler like this: protected void MyGridviewEvent(object sender,
In event handler of Form Load, I have the following code Panel pHText =
An event handler can be removed with the following code in the button click
When I write an event handler for csharp, it looks like this: public void
Following code for passing an object to event handler is not working: $('a.another').live('click', function(e,
I have the following event handler document.addEventListener('keydown', handleBodyKeyDown, false); HOW DO i prevent it

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.