• 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: packed NSTextfield and NSFormatter in IB3 plugin...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: packed NSTextfield and NSFormatter in IB3 plugin...


  • Subject: Re: packed NSTextfield and NSFormatter in IB3 plugin...
  • From: Cyril Kardassevitch <email@hidden>
  • Date: Thu, 7 Aug 2008 23:00:06 +0200

OK thanks for the tip. But it didn't work.

However the corrected code is :

- (id)initWithCoder:(NSCoder *)decoder
{
  self = [super initWithCoder:decoder];

if (self)
[self setFormatter: [decoder decodeObjectForKey:@"floatFormatter"]];


  return self;
}

- (void)encodeWithCoder:(NSCoder *)encoder
{
  [super encodeWithCoder:encoder];
  [encoder encodeObject:[self formatter] forKey:@"floatFormatter"];
}


So the problem remains the same : why the hell this attached formatter inspector can not be accessible and crash interface builder if I try so ?
Strangely this formatter is fully functional...


Cyril



Le 7 août 08 à 21:46, Michael Ash a écrit :

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


_______________________________________________

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


References: 
 >packed NSTextfield and NSFormatter in IB3 plugin... (From: Cyril Kardassevitch <email@hidden>)
 >Re: packed NSTextfield and NSFormatter in IB3 plugin... (From: Cyril Kardassevitch <email@hidden>)
 >Re: packed NSTextfield and NSFormatter in IB3 plugin... (From: "Michael Ash" <email@hidden>)

  • Prev by Date: Re: locale of embedded frameworks
  • Next by Date: Preventing deselection of NSOutlineView item
  • Previous by thread: Re: packed NSTextfield and NSFormatter in IB3 plugin...
  • Next by thread: Re: packed NSTextfield and NSFormatter in IB3 plugin...
  • Index(es):
    • Date
    • Thread