FROM : Keith Blount
DATE : Sun Nov 28 18:56:33 2004
Hello,
I am probably missing something obvious here, but if I
am, I can't find any reference to it in any of the
books on Cocoa I have nor by searching the archives...
I have some data that I use as a source for an outline
view. This uses two classes - a Document class and a
Folder class. Each document stores a pointer to its
parent folder. This is just a pointer, like this:
- (void)setParentFolder:(Folder *)folder
{
parentFolder = folder;
}
It is not retained or anything, as it doesn't require
it. My problem is, how do I encode and decode a
pointer like this in initWithCoder: and
encodeWithCoder:?
I have to archive and unarchive whenever I drag items
in the view, and since adding this instance variable,
things have gone horribly wrong. If I don't retain the
folder when I decode, the app crashes whenever I drag
and drop. If I do retain, the dragging slows down
horribly - presumably because for every document I
drag and drop, the app has to not only encode and
decode the document, but also its parent folder.
Is there anyway to maintain a simple, straightforward
pointer to another object between encoding and
decoding? I don't see how there is, because the
address in memory would change if the actual folder
item was encoded and decoded (saved and loaded)
between session, so the pointer would be invalidated
then anyway....
If anyone can point me in the direction of a solution
to this, I would be very grateful.
Many thanks,
Keith
__________________________________
Do you Yahoo!?
Yahoo! Mail - Helps protect you from nasty viruses.
http://promotions.yahoo.com/new_mail
DATE : Sun Nov 28 18:56:33 2004
Hello,
I am probably missing something obvious here, but if I
am, I can't find any reference to it in any of the
books on Cocoa I have nor by searching the archives...
I have some data that I use as a source for an outline
view. This uses two classes - a Document class and a
Folder class. Each document stores a pointer to its
parent folder. This is just a pointer, like this:
- (void)setParentFolder:(Folder *)folder
{
parentFolder = folder;
}
It is not retained or anything, as it doesn't require
it. My problem is, how do I encode and decode a
pointer like this in initWithCoder: and
encodeWithCoder:?
I have to archive and unarchive whenever I drag items
in the view, and since adding this instance variable,
things have gone horribly wrong. If I don't retain the
folder when I decode, the app crashes whenever I drag
and drop. If I do retain, the dragging slows down
horribly - presumably because for every document I
drag and drop, the app has to not only encode and
decode the document, but also its parent folder.
Is there anyway to maintain a simple, straightforward
pointer to another object between encoding and
decoding? I don't see how there is, because the
address in memory would change if the actual folder
item was encoded and decoded (saved and loaded)
between session, so the pointer would be invalidated
then anyway....
If anyone can point me in the direction of a solution
to this, I would be very grateful.
Many thanks,
Keith
__________________________________
Do you Yahoo!?
Yahoo! Mail - Helps protect you from nasty viruses.
http://promotions.yahoo.com/new_mail
| Related mails | Author | Date |
|---|---|---|
| Keith Blount | Nov 28, 18:56 | |
| Will Mason | Nov 28, 19:35 | |
| Scott Stevenson | Nov 28, 21:23 | |
| Keith Blount | Nov 29, 00:24 |






Cocoa mail archive

