version 1.1, universal binary, new xcode
[LeanCalc.git] / Sources / MyDocument.m
index 51823fe..76f6e6c 100644 (file)
@@ -11,7 +11,6 @@
 
 - num lock / esc clear expression
 
-
 */
 
 
 @implementation MyDocument
 
 - (id)init {
-
     self = [super init];
     if (!self) return nil;
-
        calculations = [[NSMutableArray alloc] init];
-       
-    return self;
+       return self;
 }
 
 
-
 - (void)dealloc {
        [calculations release];
+       [super dealloc];
 }
 
 
-
 - (void)awakeFromNib {
 
        if (![self fileName]) {
@@ -45,7 +40,6 @@
        }
        
        [arrayController setSelectionIndex:[calculations count] - 1];
-
 }
 
 
        id selectedObject = [[arrayController selectedObjects] objectAtIndex:0];
 
        return selectedObject == lastObject;
-       
 }
 
 
 - (void)addItem {
 
-       [arrayController add:self];
+       Calculation *newcalc = [[[Calculation alloc] init] autorelease];
+       [arrayController addObject:newcalc];
        int count = [calculations count];
-       id last = [calculations objectAtIndex:count - 1];
        id secondtolast = [calculations objectAtIndex:count - 2];
-       [secondtolast setValue:last forKey:@"next"];
+       [secondtolast setValue:newcalc forKey:@"next"];
        
 }
 
 }
 
 
-
-
-
 - (NSArray *)control:(NSControl *)control textView:(NSTextView *)textView completions:(NSArray *)words forPartialWordRange:(NSRange)charRange indexOfSelectedItem:(int *)index {
 
        NSString *partialWord = [[textView string] substringWithRange:charRange];
        NSArray *completions = [[[NSApplication sharedApplication] delegate] completionsForPartialWord:partialWord];
 
        return completions;
-       
 }
 
 
 
-- (NSString *)windowNibName
-{
-    // Override returning the nib file name of the document
-    // If you need to use a subclass of NSWindowController or if your document supports multiple NSWindowControllers, you should remove this method and override -makeWindowControllers instead.
+- (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.
 
+- (void)windowControllerDidLoadNib:(NSWindowController *) aController {
+    [super windowControllerDidLoadNib:aController];
 }
 
-- (NSData *)dataRepresentationOfType:(NSString *)aType {
 
+- (NSData *)dataRepresentationOfType:(NSString *)aType {
        NSMutableData *data = [[[NSMutableData alloc] init] autorelease];
        NSKeyedArchiver *archiver = [[[NSKeyedArchiver alloc] initForWritingWithMutableData:data] autorelease];
        [archiver setOutputFormat:NSPropertyListXMLFormat_v1_0];
 
 
 - (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)aType {
-
        NSKeyedUnarchiver *unarchiver = [[[NSKeyedUnarchiver alloc] initForReadingWithData:data] autorelease];
        [self setValue:[unarchiver decodeObjectForKey:@"calculations"] forKey:@"calculations"];
        [unarchiver finishDecoding];
-
     return YES;
 }