Re: Encode a 'Class' type using NSValue
Re: Encode a 'Class' type using NSValue
- Subject: Re: Encode a 'Class' type using NSValue
- From: Jens Alfke <email@hidden>
- Date: Fri, 14 May 2010 10:15:29 -0700
On May 14, 2010, at 2:45 AM, Billy Flatman wrote:
Thanks for you help. I am trying to pass the class reference around
for drag and drop, I think i'll try your idea of converting the
pointer to a number,
Encoding pointer values in archives is a very bad idea, since if the
archive gets decoded in a different process, the pointer will be
garbage and very likely to cause a crash.
You may think this isn't a problem for D&D since the result will get
used immediately, but it's fairly easily for drags to get persisted:
just drag to the Finder and you'll get a clipping file that can be
dragged back into your app at any future time. It's also possible that
another app might want to make itself interoperable with your app's
drag format, which would be impossible if you use pointers.
Why not just archive the class's name?
—Jens_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden