• 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
Archiving and NSView Subclasses
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Archiving and NSView Subclasses


  • Subject: Archiving and NSView Subclasses
  • From: Jeff LaMarche <email@hidden>
  • Date: Tue, 30 Aug 2005 19:27:38 -0400

Thanks everyone who responded to my earlier issue. Seems I did something rather stupid, which was to add the view I was palettizing to the wrong target - the palette rather than the framework target.

Now I've hit something frustrating, and I hope it's not something just as stupid. My palette is working great - I've got bindings working, the inspector working, everything seems great until I go to run a program that uses the palettized view. When the program launches, I get a SIGTRAP after getting this error message:

2005-08-30 19:10:59.144 SWSpiralViewTester[2467] An uncaught exception was raised
2005-08-30 19:10:59.145 SWSpiralViewTester[2467] *** - [NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (SWSpiralView)
2005-08-30 19:10:59.146 SWSpiralViewTester[2467] *** Uncaught exception: <NSInvalidUnarchiveOperationException> *** - [NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (SWSpiralView)


Now, I've implemented initWithCoder: and encodeWithCoder: for this view, and support keyed archiving in them. I peppered the methods with NSLog calls, and everything is working as expected within Interface Builder, but my initWithCoder does not appear to be getting called before the error above - I can't find evidence of the NSLog entries (which I didn't include in the code sample below) for initWithCoder: in my application's run log, or anywhere in Console.app (not sure where it would go being code from a framework - the entries go into Console.app when I'm running IB).

Here's the NSCoding methods I've implemented:

- (void)encodeWithCoder:(NSCoder *)coder
{
    [super encodeWithCoder:coder];
    if ([coder allowsKeyedCoding])
    {
    [coder encodeObject:[self color] forKey:@"color"];
    [coder encodeInt:[self gap] forKey:@"gap"];
    }
    else
    {
    [coder encodeObject:[self color]];
    [coder encodeValueOfObjCType:@encode(int) at:&gap];
    }
}
- (id)initWithCoder:(NSCoder *)coder
{
    self = [super initWithCoder:coder];
    if (self)
    {
    if ([coder allowsKeyedCoding])
    {
        [self setColor:[coder decodeObjectForKey:@"color"]];
        [self setGap:[coder decodeIntForKey:@"gap"]];
    }
    else
    {
        [self setColor:[coder decodeObject]];
        [coder decodeValueOfObjCType:@encode(int) at:&gap];
    }

    }
    return self;
}

If anyone knows what I'm doing wrong, I'd love to hear it.

Thanks,
Jeff
_______________________________________________
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: Archiving and NSView Subclasses
      • From: "John C. Randolph" <email@hidden>
  • Prev by Date: Re: NSSocketPort vs. AF_UNIX?
  • Next by Date: Re: Archiving and NSView Subclasses
  • Previous by thread: Re: What's happening with PNG ? (Solved)
  • Next by thread: Re: Archiving and NSView Subclasses
  • Index(es):
    • Date
    • Thread