Re: How to archive opaque CF objects
Re: How to archive opaque CF objects
- Subject: Re: How to archive opaque CF objects
- From: Chris Kane <email@hidden>
- Date: Fri, 13 Dec 2002 12:40:00 -0800
The answer to this is the same as the answer to the question: How do
you archive an ObjC object which doesn't implement or inherit NSCoding?
(Since ObjC objects are also opaque, unless you're being naughty.)
The short answer is you don't. You can only archive the information
about how a new one should be created, in the archiving of the objects
which contain such things, and have those objects create or retrieve
them in their initWithCoder:s.
Chris Kane
Cocoa Frameworks, Apple
On Thursday, December 12, 2002, at 05:29 AM, Bill Cheeseman wrote:
I would like to use NSKeyedArchiver to archive a Cocoa object that
contains,
among other things, an opaque Core Foundation object of type CFTypeRef.
As I understand the lastest Cocoa archiving documentation, I can't
encode a
CFTypeRef in an NSData object or in any other standard Cocoa object,
because
the pointer values hidden in the CFTypeRef object won't be encoded in
a way
that would allow them to be decoded correctly -- at least after the
original
object has been deallocated.
According to the docs, the recommended technique for archiving structs
and
other aggregate data types is to archive their individual fields
separately.
But CFTypeRefs are opaque and I don't know how they're structured. All
I can
do is use CF functions supplied with the CFTypeRef to get at some of
the
values. The particular CFTypeRef objects in which I'm interested don't
implement "CreateCopy" functions.
So, is it fair to say that direct archiving is not an option for
objects
containing opaque CF objects that are not toll-free bridged to a Cocoa
object type and that can't be copied?
Is my only option to call the CF functions to get those field values
that
are available through functions and to archive their results? This
seems
very awkward for situations where all I want to do is to archive an
object
temporarily, say for distribution to another process, and then
reconstitute
it on the other side. I will never be sure that I have captured all the
contents of the CFTypeRef to reconstitute it fully.
If there is a solution, it should be covered in the Carbon-Cocoa
Integration
document, but the preliminary version says nothing about this.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook - http://www.AppleScriptSourcebook.com
Vermont Recipes - http://www.stepwise.com/Articles/VermontRecipes
Croquet Club of Vermont - http://members.valley.net/croquetvermont
_______________________________________________
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.
_______________________________________________
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.