Looks like I found a solution... anyone please let me know if my solution stinks. (or any of the rest of this thing!)
In the method
- (void)windowControllerDidLoadNib:(NSWindowController *) aController
I added this:
[textView setString:[[stickitNotes objectAtIndex:0] noteBody]];





#import "MyDocument.h"

@implementation MyDocument

- (id)init
{
    self = [super init];
    if (self) {
                stickitNotes = [[NSMutableArray alloc] init];
                StickitNote *aNote = [[StickitNote alloc] init];
                [stickitNotes insertObject:aNote atIndex:0];
                currentNoteIndex = [stickitNotes indexOfObject:aNote];
    }
    return self;
}

- (NSString *)windowNibName
{
    return @"MyDocument";
}

- (void)windowControllerDidLoadNib:(NSWindowController *) aController
{
    [super windowControllerDidLoadNib:aController];
// Add any code here that needs to be executed once the windowController has loaded the document's window.
}

- (NSData *)dataRepresentationOfType:(NSString *)aType
{
        return [NSKeyedArchiver archivedDataWithRootObject:stickitNotes];
}

- (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)aType
{
        NSMutableArray *newArray;
        newArray = [NSKeyedUnarchiver unarchiveObjectWithData:data];
        
        if (newArray == nil) {
[textView setString:[[stickitNotes objectAtIndex:currentNoteIndex] noteBody]];
                [textView setNeedsDisplay:YES];
                return NO;
        } else {
                [self setStickitNotes:newArray];
[textView setString:[[stickitNotes objectAtIndex:currentNoteIndex] noteBody]];
                [textView setNeedsDisplay:YES];
                return YES;
        }
}

- (void)newNote:(id)sender
{
        
[[stickitNotes objectAtIndex:currentNoteIndex] setNoteBody: [textView string]];
        StickitNote *aNote = [[StickitNote alloc] init];
        [stickitNotes insertObject:aNote atIndex:[stickitNotes count]];
        currentNoteIndex = [stickitNotes indexOfObject:aNote];
        /* set textView to display current note */
[textView setString:[[stickitNotes objectAtIndex:currentNoteIndex] noteBody]];
        [textView setNeedsDisplay:YES];
}

- (void)nextNote:(id)sender
{
        unsigned int nextNote;
        if (currentNoteIndex == ([stickitNotes count] - 1)) {
                nextNote = 0;
        } else {
                nextNote = currentNoteIndex + 1;
        }
        
[[stickitNotes objectAtIndex:currentNoteIndex] setNoteBody: [textView string]];
        
        currentNoteIndex = nextNote;
[textView setString:[[stickitNotes objectAtIndex:currentNoteIndex] noteBody]];
        [textView setNeedsDisplay:YES];
}

- (void)previousNote:(id)sender
{
        unsigned int prevNote;
        if (currentNoteIndex == 0) {
                prevNote = ([stickitNotes count] - 1);
        } else {
                prevNote = currentNoteIndex - 1;
        }
[[stickitNotes objectAtIndex:currentNoteIndex] setNoteBody: [textView string]];
        currentNoteIndex = prevNote;
[textView setString:[[stickitNotes objectAtIndex:currentNoteIndex] noteBody]];
        [textView setNeedsDisplay:YES];
}

- (void)setStickitNotes:(NSMutableArray *)array
{
        if (array == stickitNotes)
                return; //skips if it is same data?
        [stickitNotes release];

        [array retain];

        stickitNotes = array;

        [textView setString:[stickitNotes objectAtIndex:0]];
}

@end


_______________________________________________

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