Re: NSNumber pointerValue
Re: NSNumber pointerValue
- Subject: Re: NSNumber pointerValue
- From: Dietmar Planitzer <email@hidden>
- Date: Wed, 19 Nov 2003 23:02:52 +0100
On Nov 19, 2003, at 8:45 PM, Bjvrn Carlstrvm wrote:
I'm dragging internal objects that are represented by a sting in a
list into another view. I want to create a link from the destination
to the object being dragged. My data structure requires this to be a
pointer. I looked at alternatives, draggimg the string and then after
the drag looking up the original object in a table, etc. But all the
alternatives has drawbacks and seem akward and slow.
Dragging pointers has been discussed on this messageboard before and I
believe it got the solution to convert the pointer to a NSNumber from
someone on this board. It's an elegant solution to my problem. I'm
only confused buy the behaviour of NSNumber. I think no object should
return different results before and after being placed on the
pasteboard.
Have you already tried replacing your use of NSNumber with NSValue ?
More specifically, create an NSValue instance by doing a myValue =
[NSValue valueWithPointer: myPointer] and access it via [myValue
pointerValue].
Just a guess, but it may be the case that NSNumber gets confused
because at first it gets created as an integer container, then
serialized when copied to the pasteboard and then after
de-serialization you ask it for a pointer value. NSNumber and NSValue
internally store the data type of their value.
In any case, you should never cast a pointer to an int. This works on
the current hardware and OS but is likely going to fail as soon as OS X
gets support for 64bit address spaces.
Regards,
Dietmar Planitzer
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.