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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:39:03+00:00 2026-06-16T00:39:03+00:00

I found a demo snippets which used type casting like this:(int)view.’view’ is a pointer

  • 0

I found a demo snippets which used type casting like this:(int)view.’view’ is a pointer of UIView’s object. I have never known it can be use to cast type. Someone can help me to explain it?
paste code here

- (CGPoint)accelerationForView:(UIView *)view
{
    // return
    CGPoint accelecration;

    // get acceleration
    NSValue *pointValue = [self._accelerationsOfSubViews objectForKey:
                                     [NSNumber numberWithInteger:(int)view]];
    if (pointValue == nil) {
        accelecration = CGPointZero;
    }
    else {
        [pointValue getValue:&accelecration];
    }

    return accelecration;
}

- (void)willRemoveSubview:(UIView *)subview
{
    [self._accelerationsOfSubViews removeObjectForKey:
                         [NSNumber numberWithInt:(int)subview]];
}
  • 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-16T00:39:04+00:00Added an answer on June 16, 2026 at 12:39 am
    [NSNumber numberWithInteger:(int)view]
    

    view is not an object of type UIView, it’s a pointer of type UIView*. The code above casts the pointer to an int for the purpose of storing it in a NSNumber, apparently so that it can be used as a key in a dictionary. Since pointers themselves aren’t objects, you can’t use them as dictionary keys. But if you create an instance of NSNumber from the pointer, you can use the resulting object as a key. People do this sort of thing sometimes to keep track of some information that they want to associate with a number of objects (like views) that’s not stored in the objects themselves (like acceleration).

    As I mention in my comment below, the code here uses +numberWithInteger:, which is good because that method takes a NSInteger, which will be 32 bits on a 32-bit system and 64 bits on a 64-bit system. However, the author then nullified that good decision by casting to int, which will generally be 32 bits even on a 64-bit system. The cast should really be to NSInteger, like this:

    [NSNumber numberWithInteger:(NSInteger)view]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need drag and drop boxes like igoogle.com . I found this one: http://demo.webdeveloperplus.com/drag-drop-panels/
I found this sliding panel script I like at http://www.webdesignerwall.com/demo/jquery/ , (#1 Sample Slide
I found this ajax file upload script here http://www.phpletter.com/Demo/AjaxFileUpload-Demo/ Which is supposed to add
I found the very nice demo by Oleg (http://www.ok-soft-gmbh.com/jqGrid/FillToolbarSearchFilter.htm) which shows a jqGrid toolbar
I found a tutorial with a demo on customizing the 'Facebook Like Box'; it
In one of the demo code I found following type of coding. btnLeftCard.center =
In the demo codes of dojo 1.6, I found some code like the below:
I found this demo for XNA 3 Morph target animation at Youtube: http://www.youtube.com/watch?v=e6PLtA7wgg0 And
How can I implement page navigation history, like the functionality found in: jggrid demo
i have this example found here: http://threedubmedia.com/code/event/drag/demo/resize2 and i tried to reproduce it in

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.