• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Encoding a pointer to an object, not the object itself
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Encoding a pointer to an object, not the object itself


  • Subject: Encoding a pointer to an object, not the object itself
  • From: Keith Blount <email@hidden>
  • Date: Sun, 28 Nov 2004 09:56:33 -0800 (PST)
  • Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys

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
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Encoding a pointer to an object, not the object itself
      • From: Scott Stevenson <email@hidden>
    • Re: Encoding a pointer to an object, not the object itself
      • From: Will Mason <email@hidden>
  • Prev by Date: Re: Nib files and outlets
  • Next by Date: Re: Encoding a pointer to an object, not the object itself
  • Previous by thread: Re: How to bind two combo boxes with Cocoa Bindings ?
  • Next by thread: Re: Encoding a pointer to an object, not the object itself
  • Index(es):
    • Date
    • Thread