Why are you autoreleasing the NSProgressIndicator? That means that when the pool is released, your "spinner" pointer will go stale. Odds are it will crash - not sure why it isn't doing so in the first case.

Also, if it's an IBOutlet why are you assigning to it? This isn't actually harmful, but it looks a bit odd - normally IBOutlets are set up using Interface Builder.

The probable reason that the second case doesn't work is because the init method of MyDocument isn't being called (log it or set a breakpoint). It's hard to be sure because I can't tell if the idea is that this is instantiated from the nib. If the controller isn't instantiated, the call to spinIt isn't going anywhere. Check if <theControl> is nil here - log it, set a breakpoint or NSAssert it.

But you need to fix the autorelease problem first. Why it's not crashing now I don't know - sheer luck?

hth,


G.


On 23 May 2008, at 9:43 pm, John Love wrote:

@interface Controller:NSObject {
   IBOutlet NSProgressIndicator *spinner;
   BOOL start;
}

- (IBAction) spin:(id)sender;


Within the Controller.m file, I have:

@implementation Controller

- (id) init {
   if (self = [super init]) {
       spinner = [[[NSProgressIndicator alloc] init] autorelease];
       start = TRUE;
   }

   return self;
}

_______________________________________________

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