On Thu, Aug 7, 2008 at 2:54 PM, Cyril Kardassevitch <[EMAIL PROTECTED]> 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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to