NSProgressIndicator -- delete the first message with same title
NSProgressIndicator -- delete the first message with same title
- Subject: NSProgressIndicator -- delete the first message with same title
- From: "John Love" <email@hidden>
- Date: Fri, 23 May 2008 07:43:31 -0400
I have successfully been able to create a small Cocoa multiple document
project whose GUI consists of a NSProgressIndicator, or wheel, and a Button,
titled "Spin". In the .nib window, the "Controller" is ctrl-dragged to the
wheel, specifying an outlet "wheel" and the Button is ctrl-dragged to the
Controller, specifying an action :spin:".
Within the Controller.h file, I have:
@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;
}
- (void) awakeFromNib {
[spinner setUsesThreadedAnimation:YES];
}
- (IBAction) spin:(id)sender {
if (start) [spinner startAnimation:nil];
else [spinner stopAnimation:nil];
start = !start;
}
@end
==========
Works like a champ .. pressing the Button starts, stops the spinning like it
should.
NOW .. another "speed bump" .. how to control the spinning from other
objects, i.e., no IBAction .. so, remove the Button.
Changing the spin method to look like:
- (void) spinIt:(BOOL)begin {
if (begin) [spinner startAnimation:nil];
else [spinner stopAnimation:nil];
}
Here is what I've tried, with no success:
Within MyDocument.h
@interface MyDocument:NSDocument
{
IBOutlet Controller *theControl;
}
@end
Within MyDocument.m
- (id) init {
if (self = [super init]) {
theControl = [[Controller alloc] init];
}
return self;
}
- (void) awakeFromNib {
[theControl spinIt:TRUE];
}
As I said above, it does not work; that is, I am not presented with a
spinning wheel when the new window shows. Now, I have read about
Notifications, Delegates in the Apple docs. Clearly, I do not understand
YET all of the info, but I'm getting there. If I need to factor in
Notifications and Delegates, I sure would appreciate a few snippets of
guidance and in the process be able to more completely understand these
beasts.
Thanks in advance,
John Love
_______________________________________________
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