• 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
Re: Help with simple EncodeObject & DecodeObject
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with simple EncodeObject & DecodeObject


  • Subject: Re: Help with simple EncodeObject & DecodeObject
  • From: mmalcolm crawford <email@hidden>
  • Date: Tue, 28 May 2002 01:46:42 -0700 (PDT)

On Tuesday, May 28, 2002, at 07:08AM, Marcel Weiher <email@hidden> wrote:

>On Tuesday, May 28, 2002, at 07:16 Uhr, email@hidden wrote:
>> NSMutableData *a_data = nil;
>> NSArchiver *a_archiver = [[[NSArchiver alloc]
>> initForWritingWithMutableData: [NSMutableData data]] autorelease];
>> if (a_archiver) {
>> [a_archiver encodeObject:someStr];
>> [a_archiver encodeObject:someNumber];
>> a_data = [a_archiver archiverData];
>> }
>> return a_data;
>
>You can't "push" individual data items into an archiver like this.

Umm, it turns out you can...
(Yes, I was surprised -- I wanted to check before making any assertion, hence "*may*" in my reply -- but I couldn't think of any reason why it shouldn't work, it's just calling methods...)

Nevertheless:

>I would also recommend putting your actual model-code in a class that is
>separate from the kit-supplied "Document" class.
> [...]
>There is no need to store your variables in a collection. Quite the
>contrary, they should be part of a "model" object that is referred to by
>the Document object.
>
Agreed.

>> I just want to store the internal data (the bytes of number or text).
>
If you *really* want to do this, bearing in mind you will presumably have to reconstitute your objects at some stage, you might consider overriding
- (BOOL)readFromFile:(NSString *)fileName ofType:(NSString *)docType
and
- (BOOL)writeToFile:(NSString *)fileName ofType:(NSString *)type
instead of the data representation methods...

mmalc
_______________________________________________
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.

  • Prev by Date: Re: Opening the trash in the Finder?
  • Next by Date: Re: Calling a UNIX application from a carbon app
  • Previous by thread: Re: Help with simple EncodeObject & DecodeObject
  • Next by thread: Re: Calling a UNIX application from a carbon app
  • Index(es):
    • Date
    • Thread