Using UITouch as key in NSMutableDictionary?

I'm storing some information about touches, and am using the fact that the touch objects are the same ones for the same touch. Now I wanted to make this more efficient by using the UITouch as the key in a NSMutableDictionary for faster lookup - but that doesn't work. Apparently, the dictionary tries to copy the object, but it throws an exception in some copyWithZone method.
I guess I could encapsulate the hash value in a simple class to use as the key, but I wonder if there is a better way to do this? Also, why does NSMutableDictionary try to copy the object that's used the key? Why doesn't it simply store the pointer?

From the +iPhone Application Programming Guide+
In your event-handling code you can store relevant bits of touch state for later comparison with the mutated UITouch instance. As an example, say you want to compare the final location of each touch with its original location. In the touchesBegan:withEvent: method, you can obtain the original location of each touch from the locationInView: method and store those in a CFDictionary object using the addresses of the UITouch objects as keys. Then, in the touchesEnded:withEvent: method you can use the address of each passed-in UITouch object to obtain the object’s original location and compare that with its current location. *(You should use a CFDictionary object rather than an NSDictionary object; the latter copies its keys, but the UITouch class does not adopt the NSCopying protocol, which is required for object copying.)*
http://developer.apple.com/iPhone/library/documentation/iPhone/Conceptual/iPhone OSProgrammingGuide/EventHandling/EventHandling.html#//apple_ref/doc/uid/TP400070 72-CH9-SW17

Similar Messages

  • How do I use a Tab key to maximize a frame?

    How can I use a Tab key (vk_tab) pressed on the focused frame to actually maximize the frame... what action should it have attached to it?
    thanks!

    tab is the focus traversal key, so will be consumed before getting to your listener
    try this instead
        KeyboardFocusManager.getCurrentKeyboardFocusManager()
         .addKeyEventDispatcher(new KeyEventDispatcher(){
            public boolean dispatchKeyEvent(KeyEvent e){
              if(e.getID() == KeyEvent.KEY_PRESSED)
                if(e.getKeyCode() == KeyEvent.VK_TAB ) f.setExtendedState(JFrame.MAXIMIZED_BOTH);
              return false;
        });

  • Can I use PageUp, PageDown keys

    Hello Sir/Madam
    Can I use PageUp, PageDown keys for increasing or decreasing numeric value?
    For e.g. - Lot_No is a field in a table and an item on a form. If I press PageUp key, then Lot_No should be decreased by 1 and information related to new Lot_No should be displayed. If I press PageDown key, then Lot_No should be increased by 1 and information related to new Lot_No should be displayed. The position of cursor remain on the same item.
    How can I do this? I have tried to find the solution in google, but it displays only java or .net solution. I am using Report 6i. How can I do this in PL/SQL?
    Waiting for your reply....
    Regards,
    Vikas

    Sorry this question should be asked in Forms forum.

  • Error with Links if using x3 primary keys

    Hi Folks:
    Here is the error code I'm receiving:
    ORA-01422: exact fetch returns more than requested number of rows
    Unable to fetch row.
    Background: I am using Application Express 3.2
    All of the pages I have created that rely on x2 primary keys (first_name, last_name) work fine.
    I have a table that has x3 primary keys: Table is called "time_off_awards". The x3 primary keys are: last_name, first_name, approval_date.
    I created a report that works properly and lists the awards for each person (each person can receive more than one award-on different dates).
    I also created an edit link that works properly IF *(only if)* each individual has only one award. If the individual has more than one award then I get the error above. When I set up the link I used all three keys. The x3 PK's should uniquely identify each row, but if the same last name/first name appear more than once (that is if the person has more than one award) I get the error. I thought at first maybe it was just not reading the 3rd key/part of the link (approval_date), but it shows properly if you move your cursor over the edit link.
    Here is a link to a screen pic of how I have my link set in Apex:
    [http://www.wczone.com/link_settings.gif]
    Here is a link to a pic of the report with some info:
    [http://www.wczone.com/report_link.gif]
    If needed, here is my table info:
    CREATE TABLE PERSONNEL.TIME_OFF_AWARDS (
    LAST_NAME VARCHAR2(40) NOT NULL,
    FIRST_NAME VARCHAR2(25) NOT NULL,
    APPROVAL_DATE DATE NOT NULL,
    HOURS_OFF NUMBER(3),
    CITATION VARCHAR2(1500),
    /* Keys */
    PRIMARY KEY (LAST_NAME, FIRST_NAME, APPROVAL_DATE),
    /* Foreign keys */
    CONSTRAINT TOA_PERSONNEL
    FOREIGN KEY (LAST_NAME, FIRST_NAME)
    REFERENCES PERSONNEL.MARC_PERSONNEL(LAST_NAME, FIRST_NAME)
    TABLESPACE PERSONNEL;
    Thanks for any help, I've tried looking at a couple of Apex books, but they didn't help much.
    Matt
    Edited by: user10495310 on Mar 4, 2009 8:21 AM

    Thank you everyone for the help and information you gave to me.
    Your ideas and advice helped me to think through the issues involved.
    The way i actually found to work around this issue was a little different.
    What I did was the following (which may only be usable with empty tables. If its possible to create a new column with a sequence and trigger on a table that already contains data it should work also):
    1. I removed the current PK's that were currently set.
    2. I added a single, unique PK (that used a sequence and trigger to automatically increment) to the table as was suggested in this thread and other APEX forum threads.
    3. I changed the link on the report so that it used the new PK, and also changed the PK used on the forms (under Processes - both the page rendering and page processing processes).
    The Difference:
    4. Next I changed the table (not by using APEX, but directly) from using the automatically generated ID as the PK, back to using the compound PK (x3 keys). I then added an constraint to make sure that the automatically generated column was unique. So now I have the compound PK that my supervisor wants us to use, and I'm able to use a unique, automatically generated key for APEX to use.
    I found also that if you already have a column that uses a unique/auto-generated key you can still use it with APEX without switching keys around.
    1. I added the new column to the sql in the reports source section so that the new column was searched (and then used 'hidden' so it wouldn't be displayed on the report users would see).
    2. You can still add the unique key under the processes on the form that is being linked too under the Primary key tabs. If its not a PK it won't show up in the pop up which is to the right of "Item Containing Primary Key Column Value" but it can be entered manually (i.e. p23_AUTO_ID) and it will work fine. You would also need to edit your form so that the auto ID that is being passed from the report is part of the form - but hidden if desired).

  • Can I use the CD key more than once?

    I bought Lightroom as a Christmas present for my husband this year, but his laptop was stolen recently. It will be a few months before we can afford getting him a new one, and I want him to still be able to use Lightroom until then, so I was considering installing it on my computer, if it will do so (my computer is getting a bit old). But I don't want to do that unless he'll still be able to use the CD key to install it on a new laptop once we get him one. I've never had to worry about installing software on more than one computer, so I'm not completely sure of myself here. Any advice?

    LR’s license, like most Adobe products’ licenses, is for one person on two different computers, with a desktop and a laptop or a work computer and a home computer being the typical examples, as long as only one of those computers is used at a time.

  • How can I use the function keys in a GUI with swing?

    I'm wondering how do you declare you want an action to happen when a user uses a function key or any key for that matter. How can you specify something frame wide or for that matter for a specific jtextbox?

    you need to use an accelerator
    setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK)

  • SSL: How to use the same key pair for ABAP & JAVA?

    Hello,
    I want to setup an XI (3.0 on Netweaver04)installation in the way, that ABAP AS and JAVA AS use the same key pair for SSL. My problem is to define the same private key on ABAP and JAVA. With the JAVA Administrator I am able to define or import a private key. But I could not find a possibility in ABAP to manage private keys in order to use the same on as in JAVA. What is the procedure for this?
    Thanks and Regards,
    Frank Tottleben

    Hello,
    I want to setup an XI (3.0 on Netweaver04)installation in the way, that ABAP AS and JAVA AS use the same key pair for SSL. My problem is to define the same private key on ABAP and JAVA. With the JAVA Administrator I am able to define or import a private key. But I could not find a possibility in ABAP to manage private keys in order to use the same on as in JAVA. What is the procedure for this?
    Thanks and Regards,
    Frank Tottleben

  • How to use the distinct key in formula field in SAP Crystal Reports

    I want to use the distinct key in formula field in SAP Crystal reports.
    When i'm using it shows an error.
    Please suggest me....

    Hi,
    Use DistinctCount keyword directly for your calculation instead of count(distinct(....
    Alternatively, if you want to avoid duplicate records, under "File" > "Report Options" make the 'Select Distinct Records' as True.
    Thanks,
    Raghavendra

  • How can I stop iTunes from using my multimedia keys on my keyboard?

    I use the multimedia keys on my keyboard for WinAmp, which is my primary music player.  When iTunes is open it hijacks every one of them.  WinAmp has options to enable and disable the use of global hotkeys and multimedia keys.  iTunes does not seem to.  Is there really no way to get iTunes to stop taking control of my keys?  I am using Windows 7 Home Premium 64 bit, for the record.

    Yep.  Don't manually manage.

  • Is There a way of using an alt key on the iphone (to so alt characters)

    Is There a way of using an alt key on the iphone (to so alt characters)??
    Cheers all.

    There is no alt key, so no, but there are a lot of preloaded symbols already on the phone, all you have to do is hold a key and extra options will come up. For example, if you want an accent over a, hold a, and it will give you options for it. This also works with the symbols, for example, the $ symbol can be held to provide the money symbol for euros, yens, pounds, etc.

  • Question: Inadvertently a visiting toddler gained access to my computer during a visit. He's obviously fiddled with something as I can no longer use my arrow keys to navigate through my albums or events on iPhoto. Please help!

    Question: Inadvertently a visiting toddler gained access to my computer during a visit. He's obviously fiddled with something as I can no longer use my arrow keys to navigate through my albums or events on iPhoto. Only one pic shows up in the album view - I can't see any thumbnails. To see the other pics I have to use the scroll bar on the right hand side of the window. Please help!

    Depeding on your version of iPhoto: On the left (iPhoto 11) or right (earlier versions) of the lower frame of the iPhoto Window you'll see a slider. Drag it left.
    Regards
    TD

  • Cost component Split not transferring while costing using Spec Prc Key

    Hi Fellow CO consultants,
                                             I have come across an strange scenario in my work could you help me on it . We are using special procurement key to get the prices between cross company code costing while doing costing run the Materials which have the cost component split from KKPAN (costing without quantity structure ) we find an strange behaviour of update of the costing price .
    scenario 1:That is Using KKPAN  the FG materials are costed with fixed and variable cost and are marked (future ) but not released in the Production plant . Now while doing the CK40n at warehouse level the Cost component split is correctly picked up the receiver plant using the Spec Prc key properly the fixed and variable cost split .
    But
    Scenario 2: Using KKPAN the FG materials are  costed and then price is released and the material price is at current standard price .Now while doing the CK40N run the cost component split is not picking the variable and fixed contribution its picking up the Total price of the material .( this behavior is observed only in materials done with KKPAN other materials with quantity structure provides the variable and fixed itemization even in the current price of the material ) The prerequsite of the transfer control statergy is set as fist to check the future price for the fiscal year and next the current price of the material if no future price exist. The cost component split and the costing variant are the same .
    Appreciate your thoughts .. on helping Scenario 2 case why does the cost component split take the fixed and variable cost while the price of the material is in Current.
    regards
    GK

    Dear Prasad
    Try masking costing variant too at assignment to plant and co code.
    Rajneesh

  • Using a "Posting Key" relevant for the calculation of sales

    Hi All,
    if I make a posting by F-02 using a "Posting Key" relevant for the calculation of sales, I wonder: in which table SAP registers the data of sales?
    Is there the way to modify the relevance for sales of that posting?
    Thanks

    Hi
    As far I know, sales figures are getting updated in the following summary tables:
    KCN1 for Customer related.
    LFC1 For Vendor realted.
    Regards

  • I have replaced my ibook hard drive but when I start up I get a folder with a flashing question mark. I have tried installing the OSX disk using the "C" key but can't get any further than the flashing "?." What do I do? What is the problem?

    I have replaced my ibook hard drive but when I start up I get a folder with a flashing question mark. I have tried installing the OSX disk using the "C" key but can't get any further than the flashing "?." What do I do? What is the problem?

    Which iBook do you have?
    http://support.apple.com/kb/HT1772?viewlocale=en_US
    Which version of the OS is installed, and which version are you trying to install?
    You could try starting up with Startup Manager and see if it will allow you to select the OS X install disc as the startup disk. If so, maybe you can proceed from there. I would recommend repairing the hard drive first since you are evidently having a bit of a problem with it.

  • Firefox Sync: I cannot log into my account using the sync key that was given to me and nothing I do seems to fix it. Is there anyway I can "reset" my username? I'd like to reopen an account using my same username as opposed to starting from scratch.

    I cannot log into my account using the sync key that was given to me and nothing I do seems to fix it. Is there anyway I can "reset" my username? I'd like to reopen an account using my same username as opposed to starting from scratch.

    reading through that, it doesn't look like you were given up on Candice. you never replied to StarDeb's last set of questions in that thread. she was probably waiting to hear back from you.
    why didn't you reply?

Maybe you are looking for