1

About 5 years ago, I managed to convert a pointer to a int, store it temporarily and then take that int and convert it back to a pointer (Objective-C). But I can't for my life remember how I did it.

Can anyone help me out?

EZFrag
  • 317
  • 12
  • 29
  • http://google.com/search?q=c+pointer+to+int+conversion –  Sep 02 '13 at 16:18
  • 1
    But if you don't know that, you should probably be reading an introductory C book instead of already trying to write Objective-C code. –  Sep 02 '13 at 16:19
  • Note that if you are using ARC (which you should be), this very bad idea is going to require bridging. – bbum Sep 02 '13 at 17:56
  • Actually, I haven't touched c in a few years, and the last time I used it was when I had to incorporate Adobe's Render technology into one of our iOS applications. I was a bit brain dead when I asked the question as well... In my defence... – EZFrag Sep 04 '13 at 07:59

1 Answers1

-1
int a = (int)p;

Something like that? But why? Why not just using void*?

Cy-4AH
  • 4,370
  • 2
  • 15
  • 22
  • 2
    Note that an `int` may not be large enough to hold a pointer (e.g. on a 64-bit platform). See the "possible duplicate" for better alternatives. – Martin R Sep 02 '13 at 16:56
  • Well, I have a sender variable in the function. The sender is id, but in this case it is a button. I want to store the address of an object linked to the button in the buttons tag, in order to regain a reference to it. – EZFrag Sep 04 '13 at 07:55
  • 2
    Now on the other hand, while sitting on the toilet, I realised that I have been doing this stuff for about 5 years now and that I'm not a complete noob, so let's just subclass the button and add a property for it :P – EZFrag Sep 04 '13 at 07:57