On 23 May '08, at 4:43 AM, John Love wrote:

Changing the spin method to look like:

- (void) spinIt:(BOOL)begin {
   if (begin)  [spinner startAnimation:nil];
   else        [spinner stopAnimation:nil];
}

Looks good.

@interface MyDocument:NSDocument
{
   IBOutlet Controller *theControl;
}
@end

This is fine, assuming you still have a 'Controller' object in your nib and you wire the MyDocument instance's 'theControl' outlet to point to it.

- (id) init {
   if (self = [super init]) {
       theControl = [[Controller alloc] init];
   }

   return self;
}

This part is wrong. If theControl is an IBOutlet, that means it's a pointer to an object in the nib, which will be set up for you by the nib when it loads. Assigning to it doesn't make any sense, generally. (Especially because your -init method runs before the nib sets up outlets, so whatever you assign here will be overwritten.)

Also, if you create a Controller object from scratch at runtime, that Controller won't have a spinner, since (I assume) its 'spinner' variable is an IBOutlet wired to a control in the nib. That only gets set up if there's a Controller instance in the nib, with that outlet wired up, and you use that instance.

What you want to do, I think, is to go back to the earlier working version, and replace the Controller's -spin method with your new one. Then add the 'theControl' outlet to your MyDocument class, as you already did, and wire it up in IB. That's all you need.

Now in your MyDocument methods, you can simply call [theControl spinIt: YES].

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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