Skip navigation.
 
mlRe: Passing numbers through userdata
FROM : Clark Cox
DATE : Wed Dec 15 20:13:40 2004

On Wed, 15 Dec 2004 07:31:56 -0800, Larry Fransson
<<email_removed>> wrote:
>
> On Dec 15, 2004, at 06:54, Fritz Anderson wrote:
>
> >> If I pass an int directly through the userdata property, I get the
> >> problem "warning: passing arg 3 of
> >> `addTrackingRect:owner:userData:assumeInside:' makes pointer from
> >> integer without a cast" However, it does work, even though when I
> >> retrieve the int I get the warning, "assignment makes integer from
> >> pointer without a cast"
> >
> > You could cast the integer to void * (as in userData: (void *) myInt),
> > but it is bad karma to use pointer storage for integers (and vice
> > versa, as when you do the reverse cast at the other end).
>
> Why not pass &myInt?  Wouldn't that work?


Only if you could be sure that myInt wouldn't go away or change values
before the call to -mouseEntered:. (i.e. It can't be a local variable
on the stack, etc.).

--
Clark S. Cox III
<email_removed>
http://www.livejournal.com/users/clarkcox3/
http://homepage.mac.com/clarkcox3/

Related mailsAuthorDate
mlPassing numbers through userdata Christopher Drum Dec 15, 05:56
mlRe: Passing numbers through userdata Fritz Anderson Dec 15, 15:54
mlRe: Passing numbers through userdata Larry Fransson Dec 15, 16:31
mlRe: Passing numbers through userdata Clark Cox Dec 15, 20:13