Re: packed NSTextfield and NSFormatter in IB3 plugin...
Re: packed NSTextfield and NSFormatter in IB3 plugin...
- Subject: Re: packed NSTextfield and NSFormatter in IB3 plugin...
- From: "Michael Ash" <email@hidden>
- Date: Thu, 7 Aug 2008 15:46:16 -0400
On Thu, Aug 7, 2008 at 2:54 PM, Cyril Kardassevitch <email@hidden> wrote:
> hi list,
>
> I've investigated further and try to reproduce the problem with a simpler
> configuration. So, instead of using my custom objects, I've tried to pack
> directly NSTextField and NSNumberFormatter into one object inherited from
> NSTextField. An NSNumberFormatter is generated and become the formatter for
> the object inherited from NSTextView (testIBView) during its initialization.
>
> Here is its implementation :
>
>
> // testIBView.m
>
> #import "testIBView.h"
>
> @implementation testIBView
>
> -(id)initWithFrame:(NSRect)frame
> {
> self = [super initWithFrame:frame];
>
> if (self)
> [self setFormatter:[[NSNumberFormatter alloc] init]];
>
> return self;
> }
>
> - (id)initWithCoder:(NSCoder *)decoder
> {
> self = [super initWithCoder:decoder];
>
> if (self)
> [self setFormatter:[[NSNumberFormatter alloc] initWithCoder:decoder]];
>
> return self;
> }
>
> - (void)encodeWithCoder:(NSCoder *)encoder
> {
> [super encodeWithCoder:encoder];
> [[self formatter] encodeWithCoder:encoder];
> }
>
> @end
I don't know if this is the source of your problem, but you really
shouldn't be doing things this way. You should never, ever call
initWithCoder: and encodeWithCoder: directly (unless you're writing a
subclass of NSCoder). If you want to encode and decode sub-objects,
use encodeObject:forKey: and decodeObjectForKey:.
Mike
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden