I am having some basic problems getting an indeterminate NSProgressIndicator
(INSPI) to spin.  Since I have just recently started to learn XCODE and
Cocoa, I began with "Learning Cocoa and Objective C".  I have also printed
out much of Apple's docs, e.g., on the INSPI.  I just finished developing an
app in AppleScript Studio, so I am very familiar with XCODE and IB.  Plus, a
long time ago, I delved into C++ ... so that helps ... and I have poured
over the concepts of outlets and actions and how to connect everything in IB
... but something is just not working right.  So, I decided to go from the
beginning and describe everything to you so you can tell me where "I parked
my brain".

I have developed a multi-document Cocoa app whose nib contains the usual
stuff plus a Window and an NSObject, "CalculationIndicatorController" (CIC),
whose class has the same name.  The Window has an INSPI, whose class is
CIC.  Within IB, the CIC has one outlet = "itsWindow" and one action =
"spin:".  In general, I must be doing something right, because in each
window, via CMD-N, I have a Toolbar showing ... the INSPI is just giving me
fits for now.

// CIC.h looks like:

#import <Cocoa/Cocoa.h>

@interface CIC:NSProgressIndicator {
    IBOutlet NSWindow *itsWindow;
}

- (IBAction) spin:(NSWindow *)sender on:(BOOL)start;
@end

=====

// CIC.m looks like:

#import "CIC.h"

@implementation CIC

- (id) init {
    if (self = [super init]) {
        [self setUsesThreadedAnimation:YES];
    }

    return self;
}


- (void) awakeFromNib {
    itsWindow = [self window];
    [self spin:itsWindow on:TRUE];
}


- (IBAction) spin:(NSWindow *)sender on:(BOOL)start; {
    if (start)   [self startAnimation:sender];
    else         [self stopAnimation:sender];
}

Now ... back to IB:

1) When I control-drag from the INSPI (the "lock washer") in the window to
the window's title bar, I select outlet = "itsWindow" .. so far, so good ..
but when I control-drag from the CIC in the nib window to the window's title
bar, I see TWO outlets = "itsWindow" .. so confusion #1 ??

2) Now, there is clearly an Action labelled "IBAction" in the source code
and there is an Action in the Class Actions pane of IB when I have selected
the CIC in the nib window.  As an aside, the Outlet appeared automatically
once I placed the IBOutlet in the source code .. however, even though the
IBAction was also in the source code, I had to manually add the Action =
"spin:" within IB .. so confusion #2 ??

3) So, just like I did in Apple's Currency Converter Project (whose source
for the control-drag was a Button), I control-drag from the window's title
bar to the INSPI (the "lock washer") in this window - based on the
assumption that the sender is the NSWindow (???).  I expected to be greeted
with having to select the Action = "spin:" .. but all I saw was the choice
of outlets = "delegate" and "initialFirstResponder".  The same thing
occurred when I control-drag from the window's title bar to the CIC in the
nib window.  Just for the record, I did select "initialFirstResponder" ..
but where is the Action selection = "spin:" .. confusion #3 ??

My MainDocument.m file has a *- (void)
windowControllerDidLoadNib:(NSWindowController*)aController* method which
sets up everything once the Window is showing.

But, *somewhere?,* I read that in the process of getting that Window to
show, the - (void) awakeFromNib method of each and every NSView contained
within the Window
is called.  Therefore, I called *[self spin:itsWindow on:TRUE];* within the
CIC's *awakeFromNib*.

I expected to see a rotating INSPI, or "lock washer" ... but not this trip.

Let me finish by asking one question: "Just where did I park my brain?"
_______________________________________________

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