title: Resolving cast to pointer from integer of different size error in 64-bit conversion
body: <p>I'm working on modifying the <a href="http://rogueamoeba.com/sources/" rel="nofollow noreferrer">PTHotKeyLib</a> to be 64-bit friendly, but I've run into an issue in the code that I'm not sure how to get around.  In PTHotKeyCenter, the registerHotKey method create an EventHotKeyID instance and then stuffs the of PTHotKey object into the id attribute.  The original code used a long.  I converted it to NSInteger per Apple's 64 bit programming guide.</p>
  
  <pre><code>  - (BOOL)registerHotKey:(PTHotKey *)theHotKey {
    OSStatus error;
    EventHotKeyID hotKeyID;
    EventHotKeyRef carbonHotKey;
    NSValue *key = nil;
  
    if ([[self allHotKeys] containsObject:theHotKey])
      [self unregisterHotKey:theHotKey];
  
    if (![[theHotKey keyCombo] isValidHotKeyCombo])
      return YES;
  
    hotKeyID.signature = kHotKeySignature;
    hotKeyID.id = (NSInteger)theHotKey;
    ... //Rest is not relevant
    }
  </code></pre>
  
  <p>When a user triggers the hot key, it calls the sendCarbonEvent: method that will try to pull the PTHotKey instance out of EventHotKeyID.  It worked in 32-bit land, but when compiling against 64-bit, it gives a "cast to pointer from integer of different size" warning</p>
  
  <pre><code>- (OSStatus)sendCarbonEvent:(EventRef)event {
    OSStatus error;
    EventHotKeyID hotKeyID;
    SGHotKey *hotKey;
  
    NSAssert(GetEventClass(event) == kEventClassKeyboard, @"Unknown event class");
  
    error = GetEventParameter(event,
                              kEventParamDirectObject, 
                              typeEventHotKeyID,
                              nil,
                              sizeof(EventHotKeyID),
                              nil,
                              &amp;hotKeyID);
    if (error)
      return error;
  
    NSAssert(hotKeyID.signature == kHotKeySignature, @"Invalid hot key id" );
    NSAssert(hotKeyID.id != 0, @"Invalid hot key id");
  
    hotKey = (SGHotKey *)hotKeyID.id; // warning: cast to pointer from integer of different size
  // Omitting the rest of the code
  } 
  </code></pre>
  
  <p>Switching from x86_64 back to i386 removes the warning and everything compiled and runs properly.    Under x86_64 it causes a crasher, and I'm not sure how to get around that issue.  Any suggestions on how to resolve it?  </p>