• 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: Weird coder problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Weird coder problem


  • Subject: Re: Weird coder problem
  • From: Joseph Jones <email@hidden>
  • Date: Mon, 25 Nov 2002 14:54:52 -0800

That get's me back to the original problem where it was throwing an
exception because encodeWithCoder is not implemented by NSObject.

Joe


> From: Vince DeMarco <email@hidden>
> Date: Mon, 25 Nov 2002 14:33:48 -0800
> To: Joseph Jones <email@hidden>
> Cc: Cocoa Dev <email@hidden>
> Subject: Re: Weird coder problem
>
> How about calling super in the coding methods.
>
>
> On Monday, November 25, 2002, at 12:01 PM, Joseph Jones wrote:
>
>> OK, I can't seem to figure out why my items are archiving correctly,
>> but
>> blowing up on unarchiving. There seems to be a problem with
>> unarchiving the
>> array in my class, but the call stack is blowing up in the libraries
>> and not
>> my code, which makes it a little difficult to debug. Could anyone here
>> provide an insight? I will append a cut down version of my code here:
>>
>> __________________________________________________________
>>
>> /* ProjectItem */
>>
>> #import <Cocoa/Cocoa.h>
>>
>> @interface ProjectItem : NSObject <NSCoding>
>> {
>> //Item Data
>> NSString* _title;
>>
>> //Children
>> NSMutableArray* _children;
>> }
>>
>> - (id) init;
>> - (void) dealloc;
>> - (int) numChildren;
>> - (ProjectItem*) childAtIndex:(int)index;
>> - (void) addChild:(NSString*)title;
>>
>> - (NSString*) title;
>> - (void) setTitle:(NSString*)aTitle;
>>
>> - (id) initWithCoder: (NSCoder*) decoder;
>> - (void)encodeWithCoder: (NSCoder*) encoder;
>>
>> @end
>>
>> @implementation ProjectItem
>>
>> - (id) init
>> {
>> self = [super init];
>>
>> if ( self )
>> {
>> _children = [[NSMutableArray alloc] init];
>> _title = @"";
>> }
>>
>> return self;
>> }
>>
>> - (void) dealloc
>> {
>> [_children release];
>> [_title release];
>> [super dealloc];
>> }
>>
>> - (int) numChildren
>> {
>> return [_children count];
>> }
>>
>> - (ProjectItem*) childAtIndex:(int)index
>> {
>> return [_children objectAtIndex:index];
>> }
>>
>> - (void) addChild:(NSString*)title
>> {
>> ProjectItem* item = [[ProjectItem alloc] init];
>> [item setTitle:title];
>> [_children addObject:item];
>> }
>>
>> - (NSString*) title
>> {
>> return _title;
>> }
>>
>> - (void) setTitle:(NSString*)aTitle
>> {
>> [aTitle retain];
>> [_title release];
>> _title = aTitle;
>> }
>>
>> - (void) encodeWithCoder: (NSCoder*) coder
>> {
>> if ( [coder allowsKeyedCoding] )
>> {
>> [coder encodeObject:_title forKey:@"title"];
>> [coder encodeObject:_children forKey:@"children"];
>> }
>> else
>> {
>> [coder encodeObject:_title];
>> [coder encodeObject:_children];
>> }
>> }
>>
>> - (id) initWithCoder:(NSCoder*) coder
>> {
>> self = [super init];
>> if ( self )
>> {
>> if ( [coder allowsKeyedCoding] )
>> {
>> _title = [[coder decodeObjectForKey:@"title"] retain];
>> _children = [[coder decodeObjectForKey:@"children"]
>> retain];
>> }
>> else
>> {
>> _title = [[coder decodeObject] retain];
>> _children = [[coder decodeObject] retain];
>> }
>> }
>> }
>>
>> @end
>> _______________________________________________
>> 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.

References: 
 >Re: Weird coder problem (From: Vince DeMarco <email@hidden>)

  • Prev by Date: Re: fast text
  • Next by Date: Re: fast text
  • Previous by thread: Re: Weird coder problem
  • Next by thread: SOLVED:Re: Weird coder problem
  • Index(es):
    • Date
    • Thread